Elgg  Version 2.3
edit.php
Go to the documentation of this file.
1 <?php
12 $entity = elgg_extract('entity', $vars);
13 
14 echo elgg_view_field(array(
15  '#type' => 'text',
16  'name' => 'name',
17  'value' => $entity->name,
18  '#label' => elgg_echo('user:name:label'),
19  'maxlength' => 50, // hard coded in /actions/profile/edit
20 ));
21 
23 
24 $profile_fields = elgg_get_config('profile_fields');
25 if (is_array($profile_fields) && count($profile_fields) > 0) {
26  foreach ($profile_fields as $shortname => $valtype) {
28  'guid' => $entity->guid,
29  'metadata_name' => $shortname,
30  'limit' => false
31  ));
32  if ($metadata) {
33  if (is_array($metadata)) {
34  $value = '';
35  foreach ($metadata as $md) {
36  if (!empty($value)) {
37  $value .= ', ';
38  }
39  $value .= $md->value;
40  $access_id = $md->access_id;
41  }
42  } else {
43  $value = $metadata->value;
44  $access_id = $metadata->access_id;
45  }
46  } else {
47  $value = '';
48  $access_id = ACCESS_DEFAULT;
49  }
50 
51  // sticky form values take precedence over saved ones
52  if (isset($sticky_values[$shortname])) {
53  $value = $sticky_values[$shortname];
54  }
55  if (isset($sticky_values['accesslevel'][$shortname])) {
56  $access_id = $sticky_values['accesslevel'][$shortname];
57  }
58 
59  $id = "profile-$shortname";
60  $input = elgg_view("input/$valtype", [
61  'name' => $shortname,
62  'value' => $value,
63  'id' => $id,
64  ]);
65  $access_input = elgg_view('input/access', [
66  'name' => "accesslevel[$shortname]",
67  'value' => $access_id,
68  ]);
69 
70  echo elgg_view('elements/forms/field', [
71  'input' => $input . $access_input,
72  'label' => elgg_view('elements/forms/label', [
73  'label' => elgg_echo("profile:$shortname"),
74  'id' => $id,
75  ])
76  ]);
77  }
78 }
79 
80 elgg_clear_sticky_form('profile:edit');
81 
82 echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $entity->guid));
84  '#type' => 'submit',
85  'value' => elgg_echo('save'),
86  '#class' => 'elgg-foot',
87 ]);
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$id
Edit a custom profile field.
Definition: edit.php:6
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1424
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
Definition: edit.php:19
$metadata
Definition: entity.php:19
$value
Definition: longtext.php:42
$vars['entity']
if(!is_array($accesslevel)) $profile_fields
Definition: edit.php:26
elgg echo
Translates a string.
Definition: languages.js:48
$entity
Edit profile form.
Definition: edit.php:12
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
elgg_get_metadata(array $options=array())
Returns metadata.
Definition: metadata.php:164
const ACCESS_DEFAULT
Definition: elgglib.php:2081
$sticky_values
Definition: edit.php:22
elgg_clear_sticky_form($form_name)
Remove form submission data from the session.
Definition: input.php:119
elgg_get_sticky_values($form_name, $filter_result=true)
Get all submission data cached for a form.
Definition: input.php:161