Ejemplo n.º 1
0
 public static function input($name, $value = NULL, array $attributes = NULL)
 {
     if (static::$model) {
         if (isset(static::$model->table_columns()[$name])) {
             if ($value === NULL) {
                 switch (Arr::get($attributes, 'type')) {
                     case 'checkbox':
                     case 'radio':
                         $attributes['checked'] = static::$model->{$name} == $value;
                         break;
                     case '':
                     case 'text':
                     case 'hidden':
                     case 'email':
                     case 'url':
                     case 'search':
                     case 'date':
                     case 'datetime':
                     case 'time':
                     case 'month':
                     case 'week':
                     case 'color':
                     case 'number':
                     case 'range':
                         $value = static::$model->{$name};
                         break;
                 }
             }
             $attributes['id'] = static::$model_name . '_' . URL::title($name);
             $name = static::$model_name . '[' . $name . ']';
         }
     }
     return parent::input($name, $value, $attributes);
 }
Ejemplo n.º 2
0
 public static function input($name, $value = NULL, array $attributes = NULL)
 {
     if (!isset($attributes['id']) and self::$auto_id) {
         $attributes['id'] = 'field-' . $name;
     }
     return parent::input($name, $value, $attributes) . PHP_EOL;
 }
Ejemplo n.º 3
0
 /**
  * Creates a form input. If no type is specified, a "text" type input will
  * be returned.
  *
  * @param   string  input name
  * @param   string  input value
  * @param   array   html attributes
  * @return  string
  */
 public function input($name, $value = NULL, array $attributes = NULL)
 {
     $attributes = Appform::add_class($attributes, 'text');
     $attributes['id'] = $name;
     $this->load_values($name, $value, $attributes);
     return Kohana_Form::input($name, $value, $attributes) . $this->addAlertSpan(isset($this->errors[$name]) ? $this->errors[$name] : NULL, $attributes);
 }
Ejemplo n.º 4
0
 /**
  * Creates a form input. If no type is specified, a "text" type input will be returned.
  * Added id attribute.
  *
  *     echo Form::input('username', $username);
  *
  * @param   string  $name       input name
  * @param   string  $value      input value
  * @param   array   $attributes html attributes
  * @param   array   $special
  * @return  string
  * @uses    HTML::attributes
  */
 public static function input($name, $value = NULL, array $attributes = NULL, $special = NULL)
 {
     if (!isset($attributes['id'])) {
         $attributes['id'] = $name;
     }
     if (isset($attributes['type']) and $attributes['type'] == 'hidden') {
         unset($attributes['id']);
     }
     return parent::input($name, $value, $attributes);
 }
Ejemplo n.º 5
0
 /**
  * Creates a form input. If no type is specified, a "text" type input will
  * be returned.
  *
  * @param   string  input name
  * @param   string  input value
  * @param   array   html attributes
  * @return  string
  */
 public function input($name, $value = NULL, array $attributes = NULL)
 {
     $attributes = Appform::add_class($attributes, 'text');
     $this->load_values($name, $value, $attributes);
     $result = '<li>' . Kohana_Form::input($name, $value, $attributes);
     // add error span
     if (isset($this->errors[$name])) {
         $result .= '<span class="error">' . ucfirst($this->errors[$name]) . '</span>';
     } else {
         if (isset($attributes['info'])) {
             // else add info span
             $result .= '<span class="' . $this->info_class . '">' . $attributes['info'] . '</span>';
         }
     }
     $result .= '</li>';
     return $result;
 }