Exemple #1
0
 function add_field($name, $def = array(), $order = 0)
 {
     $label = isset($def['label']) && $def['label'] ? $def['label'] : false;
     if ($label && !(substr($label, -1) == ':')) {
         unset($def['label']);
         if ($def['type'] == 'text') {
             $def['default'] = $label;
             if (!isset($def['attr']['onclick'])) {
                 $def['attr']['onclick'] = 'if (this.value==\'' . $label . '\') this.value=\'\';';
             }
             if (!isset($def['attr']['onblur'])) {
                 $def['attr']['onblur'] = 'if (this.value==\'\') this.value=\'' . $label . '\';';
             }
         }
     }
     parent::add_field($name, $def, $order);
     if (array_search($def['type'], array('select', 'multiselect')) !== FALSE) {
         $default_text = 'option_text_default_' . $name;
         $this->{$default_text} = $label;
     }
 }