Cake\View\Helper\FormHelper::_getInput PHP Method

_getInput() protected method

Generates an input element
protected _getInput ( string $fieldName, array $options ) : string
$fieldName string the field name
$options array The options for the input element
return string The generated input element
    protected function _getInput($fieldName, $options)
    {
        switch (strtolower($options['type'])) {
            case 'select':
                $opts = $options['options'];
                unset($options['options']);
                return $this->select($fieldName, $opts, $options);
            case 'radio':
                $opts = $options['options'];
                unset($options['options']);
                return $this->radio($fieldName, $opts, $options);
            case 'multicheckbox':
                $opts = $options['options'];
                unset($options['options']);
                return $this->multiCheckbox($fieldName, $opts, $options);
            case 'input':
                throw new RuntimeException("Invalid type 'input' used for field '{$fieldName}'");
            default:
                return $this->{$options['type']}($fieldName, $options);
        }
    }

Usage Example

 protected function _getInput($fieldName, $options)
 {
     if (isset($options['type']) && !in_array($options['type'], ['radio', 'checkbox', 'datetime'])) {
         $options = $this->addClass($options, 'form-control');
     }
     return parent::_getInput($fieldName, $options);
 }
All Usage Examples Of Cake\View\Helper\FormHelper::_getInput