Ejemplo n.º 1
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->htmlOptions = WhHtml::defaultOption('autocomplete', 'off', $this->htmlOptions);
     $this->htmlOptions = WhHtml::addClassName('grd-white', $this->htmlOptions);
     $this->initOptions();
 }
Ejemplo n.º 2
0
 /**
  * Helper method to display different input types for the different complain bootstrap forms wrapped with their
  * labels, help and error messages. This method is a replacement of the old 'typeRow' methods from Yii-Bootstrap
  * extension. Example:
  * <pre>
  *     $form->row(WhHtml::INPUT_TEXT, $model, 'attribute', array('style'=>'width:125px'));
  *    $form->row(WhHtml::INPUT_DROPDOWN, $model, 'attribute', array('a'=>'A','b'=>'B'), array());
  * </pre>
  * @param $type
  * @param $model
  * @param $attribute
  * @param $data
  * @param array $htmlOptions
  * @return string
  * @throws CException
  */
 public function row($type, $model, $attribute, $data = array(), $htmlOptions = array())
 {
     if (!in_array($type, WhHtml::validInputs())) {
         throw new CException(Yii::t('tb', 'Unrecognized input type'));
     }
     $labelOptions = WhHtml::popOption('labelOptions', $htmlOptions, array());
     $errorOptions = WhHtml::popOption('errorOptions', $htmlOptions, array());
     $containerOptions = WhHtml::popOption('containerOptions', $htmlOptions, array());
     $labelOptions = WhHtml::defaultOption('formType', $this->type, $labelOptions);
     ob_start();
     // make sure it holds the class control-label
     if ($this->type === WhHtml::FORM_HORIZONTAL) {
         echo CHtml::openTag('div', WhHtml::addClassName('control-group', $containerOptions));
     }
     // form's inline do not render labels and radio|checkbox input types render label's differently
     if ($this->type !== WhHtml::FORM_INLINE && !preg_match('/radio|checkbox/i', $type) && WhHtml::popOption('label', $htmlOptions, true)) {
         echo CHtml::activeLabel($model, $attribute, $labelOptions);
     } elseif (preg_match('/radio|checkbox/i', $type)) {
         $htmlOptions['labelOptions'] = $labelOptions;
     }
     if (WhHtml::popOption('block', $htmlOptions, false)) {
         $htmlOptions = WhHtml::addClassName('input-block-level', $htmlOptions);
     }
     $params = in_array($type, WhHtml::$dataInputs) ? array($model, $attribute, $data, $htmlOptions) : array($model, $attribute, $htmlOptions);
     $errorSpan = $this->error($model, $attribute, $errorOptions);
     echo $this->wrapControl(call_user_func_array('WhHtml::active' . ucfirst($type), $params), $errorSpan);
     /* since PHP 5.3 */
     if ($this->type == WhHtml::FORM_VERTICAL && WhHtml::popOption('error', $htmlOptions, true)) {
         echo $errorSpan;
     }
     if ($this->type == WhHtml::FORM_HORIZONTAL) {
         echo '</div>';
     }
     return ob_get_clean();
 }