/**
  * Overwrite FormHelper::_getInput()
  *
  * - Wrap `<div>` input element
  * - Generates an input element
  *
  * @param array $args The options for the input element
  * @return string The generated input element
  */
 protected function _getInput($args)
 {
     $input = parent::_getInput($args);
     if (!empty($this->_inputOptions['help_inline'])) {
         $input .= ' ' . $this->Html->tag('span', $this->_inputOptions['help_inline'], array('class' => 'help-inline'));
     }
     if ($this->_inputType === 'checkbox' && $this->_inputOptions['checkboxDiv'] !== false) {
         $input = $this->Html->div($this->_inputOptions['checkboxDiv'], $input);
     }
     $beforeInput = $this->_inputOptions['beforeInput'];
     $afterInput = $this->_inputOptions['afterInput'];
     $helpBlock = '';
     if (!empty($this->_inputOptions['help_block'])) {
         $helpBlock = $this->Html->tag('span', $this->_inputOptions['help_block'], array('class' => 'help-block'));
     }
     $error = null;
     $errorOptions = $this->_extractOption('error', $this->_inputOptions, null);
     $errorMessage = $this->_extractOption('errorMessage', $this->_inputOptions, true);
     if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
         $errMsg = $this->error($this->_fieldName, $errorOptions);
         if ($errMsg && $errorMessage) {
             $error = $errMsg;
         }
     }
     $html = $beforeInput . $input . $afterInput . $helpBlock . $error;
     if ($this->_divOptions) {
         $tag = $this->_divOptions['tag'];
         unset($this->_divOptions['tag']);
         $html = $this->Html->tag($tag, $html, $this->_divOptions);
     }
     return $html;
 }
 /**
  * Overwrite FormHelper::_getInput()
  *
  * - Wrap `<div>` input element
  * - Generates an input element
  *
  * @param array $args The options for the input element
  * @return string The generated input element
  */
 protected function _getInput($args)
 {
     $input = parent::_getInput($args);
     if ($this->_inputType === 'checkbox' && $this->_inputOptions['checkboxDiv'] !== false) {
         $input = $this->Html->div($this->_inputOptions['checkboxDiv'], $input);
     }
     $beforeInput = $this->_inputOptions['beforeInput'];
     $afterInput = $this->_inputOptions['afterInput'];
     $error = null;
     $errorOptions = $this->_extractOption('error', $this->_inputOptions, null);
     $errorMessage = $this->_extractOption('errorMessage', $this->_inputOptions, true);
     if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
         $errMsg = $this->error($this->_fieldName, $errorOptions);
         if ($errMsg && $errorMessage) {
             $error = $errMsg;
         }
     }
     $html = $beforeInput . $input . $afterInput . $error;
     if ($this->_divOptions) {
         $tag = $this->_divOptions['tag'];
         unset($this->_divOptions['tag']);
         $html = $this->Html->tag($tag, $html, $this->_divOptions);
     }
     return $html;
 }
 /**
  * Overwrites parent method to generate a custom input.
  *
  * @param type $args
  * @return string
  */
 protected function _getInput($args)
 {
     $type = $this->_currentInputType = $args['type'];
     $options = $this->currentInputOptions;
     $customOptions = $this->currentInputOptions['custom'];
     // TODO: ver esto... Si es de tipo select multiple con checkbox, no setear clase en checkoxes
     if (in_array($type, array('checkbox', 'hidden')) || $args['type'] == 'select' && isset($args['options']['multiple']) && $args['options']['multiple'] == 'checkbox' && $args['options']['class'] == 'form-control') {
         unset($args['options']['class']);
     }
     // Render input field via parent method
     $input = parent::_getInput($args);
     if ($type == 'hidden') {
         return $input;
     }
     // Prepend beforeInput and append afterInput to generated input field
     $html['input'] = $this->_getCustom('beforeInput') . $input . $this->_getCustom('afterInput');
     // Checkbox label rendering
     if ($type == 'checkbox') {
         if ($this->_getCustom('checkboxLabel')) {
             $options = $this->domId($args);
             $html['input'] .= ' ' . $customOptions['checkboxLabel'];
             $html['input'] = $this->Html->tag('label', $html['input'], array('for' => $options['id']));
         }
         $html['input'] = $this->Html->tag('div', $html['input'], array('class' => 'checkbox'));
     }
     // Error rendering, overwrites parent rendering
     $html['error'] = null;
     $errorOptions = $this->_extractOption('error', $options, null);
     if ($this->_inputType !== 'hidden' && $errorOptions !== false) {
         $html['error'] = $this->error($this->_fieldName, $errorOptions);
     }
     // Help block rendering
     $html['help'] = null;
     if (!empty($customOptions['help'])) {
         $html['help'] = $this->Html->tag('div', $customOptions['help'], array('class' => 'help-block'));
     }
     // Set size of input if enabled, and get full html of input and block
     if (!empty($customOptions['wrap'])) {
         if ($customOptions['externalWrap']) {
             $html['input'] = $this->Html->tag('div', $html['input'], array('class' => $customOptions['wrap']));
             $html['input'] = $this->Html->tag('div', $html['input'], array('class' => 'row'));
             if ($customOptions['externalWrap']) {
                 $fullHtml = $html['input'] . $html['error'] . $html['help'];
                 $fullHtml = $this->Html->tag('div', $fullHtml, array('class' => $customOptions['externalWrap']));
             }
         } else {
             $fullHtml = $html['input'] . $html['error'] . $html['help'];
             $fullHtml = $this->Html->tag('div', $fullHtml, array('class' => $customOptions['wrap']));
         }
     } else {
         $fullHtml = $html['input'] . $html['error'] . $html['help'];
     }
     return $fullHtml;
 }