Elgg  Version master
Variables
select.php File Reference

Go to the source code of this file.

Variables

 $vars ['class'] = elgg_extract_class($vars, ['elgg-input-select'])
 Elgg select input Displays a select input field. More...
 
 $defaults
 
 $options_values = []
 
 $options = elgg_extract('options', $vars, [])
 
 $normalize_options
 
 $value = is_array($vars['value']) ? $vars['value'] : [$vars['value']]
 
 $vars ['multiple'] = !empty($vars['multiple'])
 
if($vars['multiple']&&!empty($vars['name'])&&is_string($vars['name'])) $render_option
 
 $options_list = ''
 
 foreach ($options_values as $option)
 

Variable Documentation

$defaults
Initial value:
= [
'value' => ''

Definition at line 27 of file select.php.

$normalize_options
Initial value:
= function($options) use (&$normalize_options) {
foreach ($options as $key => $option) {
if (!is_array($option)) {
$option = [
'text' => $option,
'value' => $key,
];
}
$optgroup = elgg_extract('options', $option);
if (is_array($optgroup)) {
$option['options'] = $normalize_options($optgroup);
}
$options[$key] = $option;
}
return $options;
}
$options
Definition: select.php:36
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
$normalize_options
Definition: select.php:58
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44

Definition at line 58 of file select.php.

$options = elgg_extract('options', $vars, [])

Definition at line 36 of file select.php.

$options_list = ''

Definition at line 114 of file select.php.

$options_values = []

Definition at line 33 of file select.php.

if ($vars['multiple']&&!empty($vars['name'])&&is_string($vars['name'])) $render_option
Initial value:
= function($option) use ($value) {
$opt_value = elgg_extract('value', $option);
$text = elgg_extract('text', $option);
unset($option['text']);
if (!is_string($text) && !is_numeric($text)) {
elgg_log('No text defined for input/select option with value "' . $opt_value . '"', \Psr\Log\LogLevel::NOTICE);
}
if (!isset($option['selected'])) {
$option['selected'] = isset($opt_value) && in_array((string) $opt_value, $value);
}
if (!isset($option['title'])) {
$option['title'] = $text;
}
return elgg_format_element('option', $option, $text);
}
$value
Definition: select.php:80
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:86
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$text
Definition: button.php:33

Definition at line 93 of file select.php.

$value = is_array($vars['value']) ? $vars['value'] : [$vars['value']]

Definition at line 80 of file select.php.

$vars = elgg_extract_class($vars, ['elgg-input-select'])

Elgg select input Displays a select input field.

Warning
Values of FALSE or NULL will match '' (empty string) but not 0.

$vars['value'] The current value or an array of current values if multiple is true $vars['options'] An array of strings or arrays representing the options for the dropdown field. If an array is passed, the "text" key is used as its text, all other elements in the array are used as attributes. $vars['options_values'] An associative array of "value" => "option" where "value" is the name and "option" is the value displayed on the button. Replaces $vars['options'] when defined. When "option" is passed as an array, the same behaviour is used as when the $vars['options'] is passed an array to. If the array contains an array of 'options' an optgroup will be drawn with 'label' as the optgroup label. $vars['multiple'] If true, multiselect of values will be allowed in the select box $vars['class'] Additional CSS class

Definition at line 25 of file select.php.

$vars['multiple'] = !empty($vars['multiple'])

Definition at line 84 of file select.php.

foreach($options_values as $option)

Definition at line 116 of file select.php.