예제 #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);
 }
예제 #2
0
파일: form.php 프로젝트: TdroL/hurtex
 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;
 }
예제 #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);
 }
예제 #4
0
파일: Form.php 프로젝트: eok8177/shopCMS
 /**
  * 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);
 }
예제 #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;
 }