Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
tags.php
Go to the documentation of this file.
1 <?php
12 $vars['class'] = (array) elgg_extract('class', $vars, []);
13 $vars['class'][] = 'elgg-input-tags';
14 
15 $defaults = array(
16  'value' => '',
17  'disabled' => false,
18  'autocapitalize' => 'off',
19  'type' => 'text'
20 );
21 
22 if (isset($vars['entity'])) {
23  $defaults['value'] = $vars['entity']->tags;
24  unset($vars['entity']);
25 }
26 
27 $vars = array_merge($defaults, $vars);
28 
29 if (is_array($vars['value'])) {
30  $tags = array();
31 
32  foreach ($vars['value'] as $tag) {
33  if (is_string($tag)) {
34  $tags[] = $tag;
35  } else {
36  $tags[] = $tag->value;
37  }
38  }
39 
40  $vars['value'] = implode(", ", $tags);
41 }
42 
43 echo elgg_format_element('input', $vars);
$vars['class']
Elgg tag input Displays a tag input field.
Definition: tags.php:12
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:218
if(empty($vars['tags'])&&(!empty($value)||$value===0||$value=== '0')) if(empty($vars['tags'])&&$value!==0 &&$value!== '0') $tags
Definition: tags.php:28
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:1310
$defaults
Definition: tags.php:15