Example #1
0
 /**
  * Adds Bootstrap-style class name to error messages
  * @param string $field
  * @param null $text
  * @param array $options
  * @return string
  */
 public function error($field, $text = null, $options = array())
 {
     if (!empty($this->request->params['admin'])) {
         $options['class'] = 'help-inline';
     }
     return parent::error($field, $text, $options);
 }
 /**
  * Render error messages
  *
  * @param string $field
  * @param mixed $text
  * @param array $options
  *
  * @return string
  */
 public function error($field, $text = null, $options = array())
 {
     // The only way currently to catch Model Relation validation errors :(
     if ($field[0] == ucfirst($field[0])) {
         $field = sprintf('%s.%s', $this->_modelScope, $field);
     }
     return parent::error($field, $text, $options);
 }
Example #3
0
 function error($field, $text = null, $options = array())
 {
     $defaults = array('wrap' => true);
     $options = array_merge($defaults, $options);
     return parent::error($field, $text, $options);
 }
 /**
  *
  * Create & return a error message (Twitter Bootstrap like).
  *
  * The error is wrapped in a <span> tag, with a class
  * according to the form type (help-inline or help-block).
  *
  **/
 public function error($field, $text = null, $options = array())
 {
     $this->setEntity($field);
     $optField = $this->_magicOptions(array());
     $options['wrap'] = $this->_extractOption('wrap', $options, 'span');
     $errorClass = 'help-block';
     if ($this->horizontal && $optField['type'] != 'checkbox' && $optField['type'] != 'radio') {
         $errorClass .= ' ' . $this->_getColClass('error');
     }
     $options = $this->addClass($options, $errorClass);
     return parent::error($field, $text, $options);
 }
 public function error($field, $options = array(), $text = NULL)
 {
     $commons['escape'] = false;
     $commons['wrap'] = false;
     return parent::error($field, $text, array_merge($commons, $options));
 }
 protected function _clearfix($name, $input, $options)
 {
     $default = array('label' => null, 'type' => null, 'div' => array('class' => 'controls'));
     $options = Set::merge($default, $options);
     $out = array();
     if ($options['label'] !== false) {
         $text = $options['label']['text'];
         if ($options['type'] === 'checkbox') {
             unset($options['label']['text']);
             $options['label']['for'] = '';
         }
         $out[] = parent::label(FALSE, $text, $options['label']);
     }
     $out[] = $this->Html->div($options['div']['class'], $input, $options['div']);
     $clearfix = 'control-group';
     if (parent::error($name)) {
         $clearfix .= ' error';
     }
     return $this->Html->div($clearfix, implode("\n", $out));
 }
 /**
  * Adds the class `help-inline` as its required by bootstrap
  *
  */
 public function error($field, $text = null, $options = array())
 {
     $defaults = array('class' => 'help-inline');
     $options = Set::merge($defaults, $options);
     return parent::error($field, $text, $options);
 }
Example #8
0
 /**
  * @link http://book.cakephp.org/view/1423/error
  */
 function error($field, $text = null, $options = array())
 {
     $defaults = array('wrap' => 'p', 'class' => 'message error', 'escape' => true);
     $options = array_merge($defaults, $options);
     return parent::error($field, $text, $options);
 }
 /**
  * Create & return a error message (Twitter Bootstrap like).
  * 
  * The error is wrapped in a <span> tag, with a class
  * according to the form type (help-inline or help-block).
  *
  * @param string $field Field name.
  * @param string $text Error message.
  * @param array $options Array of options to passed to parent::error().
  * @return string HTML string of the error message for the field.
  */
 public function error($field, $text = null, $options = [])
 {
     $this->setEntity($field);
     $optField = $this->_magicOptions([]);
     $options['wrap'] = $this->_extractOption('wrap', $options, 'span');
     $errorClass = GA_HELP_BLOCK;
     if ($this->formType === GA_INLINE) {
         $errorClass = GA_HELP_INLINE;
     }
     $options = $this->addClass($options, $errorClass);
     return parent::error($field, $text, $options);
 }
 function multipleSelectBoxes($fieldName, $options = array())
 {
     $label = null;
     if (!empty($options['label'])) {
         $label = $options['label'];
     }
     $options['label'] = false;
     $model = $this->model();
     $view =& ClassRegistry::getObject('view');
     $this->setEntity($fieldName);
     $tr_class = '';
     if (in_array($this->field(), $this->fieldset['validates'])) {
         $tr_class = ' class="required"';
     }
     $out = '';
     $out .= '<tr' . $tr_class . '>';
     $out .= '<th>';
     $out .= parent::label($fieldName, $label);
     $out .= '</th>';
     $out .= '<td>';
     $options['div'] = false;
     $varName = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $this->field())));
     $users = $view->getVar($varName);
     $selects = array();
     $attributes = $this->value($options);
     if (!empty($attributes['value'])) {
         foreach ($attributes['value'] as $selected) {
             $selects[$selected] = $users[$selected];
             unset($users[$selected]);
         }
     }
     if (!empty($options['options'])) {
         $selects = $options['options'];
         $key = key($options['options']);
         unset($users[$key]);
         unset($options['options']);
     }
     $out .= parent::input($fieldName, array_merge($options, array('options' => $selects, 'error' => false)));
     $out .= parent::input('all', array_merge($options, array('type' => 'select', 'options' => $users, 'error' => false)));
     $out .= parent::error($fieldName);
     $script = 'createMovableOptions("' . $model . 'All","' . $fieldName . $fieldName . '",500,300,"' . __d('tools', $fieldName, true) . '","' . $label . '");';
     $out .= $this->Javascript->codeBlock($script, array('inline' => true));
     $this->Javascript->link('multipleselectboxes.js', false);
     $this->Html->css('multipleselectboxes.css', null, array(), false);
     $out .= '</td>';
     $out .= '</tr>';
     return $out;
 }