form::input PHP Method

input() public static method

public static input ( $type, $name, $value = '', $attributes = [] )
    public static function input($type, $name, $value = '', $attributes = array())
    {
        $attributes['type'] = $type;
        $attributes['name'] = $name;
        if ($value) {
            $attributes['value'] = $value;
        }
        return Html::element('input', '', $attributes);
    }

Usage Example

Example #1
0
 public function html_element()
 {
     // Import base data
     $data = $this->data;
     $input = '';
     foreach ($this->parts as $type => $val) {
         isset($data['value']) or $data['value'] = '';
         $temp = $data;
         $temp['name'] = $this->data['name'] . '[' . $type . ']';
         $offset = strlen($data['value']) == 10 ? 0 : 3;
         switch ($type) {
             case 'area_code':
                 if (strlen($data['value']) == 10) {
                     $temp['value'] = substr($data['value'], 0, 3);
                 } else {
                     $temp['value'] = '';
                 }
                 $temp['class'] = 'area_code';
                 $input .= form::input(array_merge(array('value' => $val), $temp)) . '-';
                 break;
             case 'exchange':
                 $temp['value'] = substr($data['value'], 3 - $offset, 3);
                 $temp['class'] = 'exchange';
                 $input .= form::input(array_merge(array('value' => $val), $temp)) . '-';
                 break;
             case 'last_four':
                 $temp['value'] = substr($data['value'], 6 - $offset, 4);
                 $temp['class'] = 'last_four';
                 $input .= form::input(array_merge(array('value' => $val), $temp));
                 break;
         }
     }
     return $input;
 }
All Usage Examples Of form::input