For more details and usage information on ActiveField, see the guide article on forms.
부터: 2.0
저자: Qiang Xue (qiang.xue@gmail.com)
상속: extends yii\base\Component
예제 #1
1
 public function timepickerInput($options = [])
 {
     TimePickerAsset::register($this->form->getView());
     $this->registerScript($options);
     return parent::textInput();
 }
예제 #2
0
 public function begin()
 {
     if ($this->collapsed == true) {
         $this->options["class"] .= " collapsed-box";
     }
     return parent::begin();
 }
예제 #3
0
    public function init(){

        //Changing Input Options Merge with form-class
        $this->inputOptions = ['placeHolder' => $this->model->getAttributeLabel($this->attribute), 'class' => 'form-control'];

        parent::init();
    }
예제 #4
0
 /**
  * @inheritdoc
  */
 public function checkbox($options = [], $enclosedByLabel = true)
 {
     if (isset($this->inputOptions['name'])) {
         $options['name'] = $this->inputOptions['name'];
     }
     return parent::checkbox($options, $enclosedByLabel);
 }
예제 #5
0
 public function render($content = null)
 {
     if (!isset($this->parts['{hider}'])) {
         $this->parts['{hider}'] = "<a href='#' style = 'margin-top:2px;margin-bottom:2px;\n\t\tfloat: right;padding-right: 4px;padding-left: 5px;padding-top: 2px;padding-bottom: 0px'\n\t \tclass = 'btn btn-default put-on-cloak' value = {$this->attribute}><span style = 'color:#C0C0C0' class = 'glyphicon glyphicon-remove' ></a>";
     }
     return parent::render();
 }
예제 #6
0
 public function dropDownList($items, $options = [], $generateDefault = true)
 {
     if ($generateDefault === true && !isset($options['prompt'])) {
         $options['prompt'] = '请选择';
     }
     return parent::dropDownList($items, $options);
 }
예제 #7
0
 public function init()
 {
     parent::init();
     /*$this->owner->addRule($this->getAttributeName(), 'in', [
           'range' => $this->getOptions(),
           'allowArray' => true,
       ]);*/
 }
예제 #8
0
 public function render($content = null)
 {
     if (!isset($this->parts['{hint}']) || $this->parts['{hint}'] === null) {
         $this->template = str_replace("\n{hint}", '', $this->template);
     }
     $this->prepareTemplate();
     return parent::render($content);
 }
예제 #9
0
 public function render($content = null)
 {
     $label = $this->model->getAttributeLabel($this->attribute);
     $this->html = ArrayHelper::merge(['caption' => $label], $this->html);
     $this->inputOptions['placeholder'] = $this->inputOptions['placeholder'] ? $this->inputOptions['placeholder'] : $label;
     $this->html['attr'] = $this->html['attr'] ? $this->html['attr'] . " placeholder='{$this->inputOptions['placeholder']}'" : "placeholder='{$this->inputOptions['placeholder']}'";
     if ($this->form->autogenerate) {
         return '';
     }
     $this->parts['{error}'] = '';
     return parent::render($content);
 }
예제 #10
0
 public function textarea($options = [])
 {
     if (!isset($options['rows'])) {
         $options['rows'] = 5;
     }
     return parent::textarea($options);
 }
예제 #11
0
 /**
  * @inheritdoc
  */
 public function widget($class, $config = [])
 {
     $config = array_merge(['options' => $this->inputOptions], $config);
     return parent::widget($class, $config);
 }
 /**
  * @inheritdoc
  */
 public function widget($class, $config = [])
 {
     if (property_exists($class, 'disabled') && property_exists($class, 'readonly')) {
         $this->initDisability($config);
     }
     return parent::widget($class, $config);
 }
예제 #13
0
 /**
  * Returns the JS options for the field.
  * @return array the JS options
  */
 public function getClientOptions()
 {
     return parent::getClientOptions();
 }
예제 #14
0
 /**
  * Renders switcher
  * @see http://materializecss.com/forms.html#switches
  * @param array $options
  * @param array $flags
  * @return $this
  */
 public function switcher($options = [], $flags = null)
 {
     parent::checkbox($options, false);
     if ($flags === null) {
         $label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
         $labelParts = explode(',', $label);
         $flags = count($labelParts) >= 2 ? $labelParts : null;
     }
     if ($flags) {
         Html::removeCssClass($this->options, 'input-field');
         Html::addCssClass($this->options, 'switch');
         $labelContent = $flags[0] . $this->parts['{input}'] . Html::tag('span', '', ['class' => 'lever']) . $flags[1];
         $this->parts['{input}'] = Html::label($labelContent, Html::getInputId($this->model, $this->attribute));
     }
     return $this;
 }
예제 #15
0
 public function checkbox($options = [], $enclosedByLabel = false)
 {
     parent::checkbox($options, $enclosedByLabel);
     return $this;
 }
예제 #16
0
 /**
  * Skip \kartik\form\ActiveField::checkbox()
  * @see \kartik\form\ActiveField::checkbox()
  */
 public function checkbox($options = [], $enclosedByLabel = true)
 {
     return grandParent::checkbox($options, $enclosedByLabel);
 }
예제 #17
0
    /**
     * @inheritdoc
     */
    public function render($content = null)
    {
        if ($this->getConfigParam('showHints') === false) {
            $this->hintOptions['hint'] = '';
        } else {
            if ($content === null && !isset($this->parts['{hint}']) && !isset($this->hintOptions['hint'])) {
                $this->hintOptions['hint'] = $this->generateHint();
            }
            $this->template = strtr($this->template, ['{hint}' => $this->_settings['hint']]);
        }

        if ($this->form->staticOnly === true) {
            $field = $this->staticInput();
            $this->buildTemplate();
            return parent::render(null);
        }
        $this->initPlaceholder($this->inputOptions);
        $this->initDisability($this->inputOptions);
        $this->buildTemplate();
        return parent::render($content);
    }
예제 #18
0
 /**
  * @inheritdoc
  */
 public function checkboxList($items, $options = [], $item_options = [])
 {
     $options['item'] = function ($index, $label, $name, $checked, $value) use($item_options) {
         $options = ['value' => $value, 'label' => $label, 'ng-model' => 'data.' . $this->attribute . '.' . $value];
         if (isset($item_options[$value])) {
             $options = array_merge($options, $item_options[$value]);
         }
         return Html::tag('md-checkbox', $label, $options);
     };
     return parent::checkboxList($items, $options);
 }
 public function render($content = null)
 {
     $this->inputOptions['placeholder'] = is_null($this->inputOptions['placeholder']) ? $this->model->getAttributeLabel($this->attribute) : null;
     $this->registerStyles();
     return parent::render($content);
 }
예제 #20
0
 /**
  * @inherit doc
  */
 public function render($content = null)
 {
     if ($this->form->staticOnly === true) {
         $field = $this->staticInput();
         $this->initTemplate();
         $this->buildTemplate();
         return parent::render(null);
     }
     $this->initTemplate();
     $this->initPlaceholder($this->inputOptions);
     $this->initAddon();
     $this->initDisability($this->inputOptions);
     $this->buildTemplate();
     return parent::render($content);
 }
예제 #21
0
 /**
  * Useful to test other methods from ActiveField, that call ActiveField::getClientOptions()
  * but it's return value is not relevant for the test being run.
  */
 public function getClientOptions()
 {
     return $this->getClientOptionsEmpty ? [] : parent::getClientOptions();
 }
예제 #22
0
 /**
  *
  * Стандартная обработка поля формы.
  *
  * @param \yii\widgets\ActiveField $field
  * @return \yii\widgets\ActiveField
  */
 public function postFieldRender(\yii\widgets\ActiveField $field)
 {
     if ($this->property->hint) {
         $field->hint((string) $this->property->hint);
     }
     if ($this->property->name) {
         $field->label($this->property->name);
     } else {
         $field->label(false);
     }
     return $field;
 }
예제 #23
0
 /**
  * Initializes the widget.
  * This renders the form open tag.
  */
 public function init()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if (!isset($this->fieldConfig['class'])) {
         $this->fieldConfig['class'] = ActiveField::className();
     }
     echo Html::beginForm($this->action, $this->method, $this->options);
 }
예제 #24
0
 public function render($content = null)
 {
     $this->registerStyles();
     return parent::render($content);
 }
예제 #25
0
 /**
  * @inheritdoc
  */
 public function label($label = null, $options = [])
 {
     if (is_bool($label)) {
         $this->enableLabel = $label;
         if ($label === false && $this->form->layout === 'horizontal') {
             Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']);
         }
     } else {
         $this->enableLabel = true;
         $this->renderLabelParts($label, $options);
         parent::label($label, $options);
     }
     return $this;
 }
예제 #26
0
 /**
  * @inheritdoc
  */
 public function label($label = null, $options = [])
 {
     if (is_bool($label)) {
         $this->enableLabel = $label;
     } else {
         $this->enableLabel = true;
         $this->renderLabelParts($label, $options);
         parent::label($label, $options);
     }
     return $this;
 }
 /**
  * @inheritdoc
  */
 public function render($content = null)
 {
     if ($content === null) {
         if ($this->enableLabel === false) {
             $this->parts['{label}'] = '';
             $this->parts['{beginLabel}'] = '';
             $this->parts['{labelTitle}'] = '';
             $this->parts['{endLabel}'] = '';
         } elseif (!isset($this->parts['{beginLabel}'])) {
             $this->renderLabelParts();
         }
         if ($this->enableError === false) {
             $this->parts['{error}'] = '';
         }
         if ($this->inputTemplate) {
             $input = isset($this->parts['{input}']) ? $this->parts['{input}'] : Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
             $this->parts['{input}'] = strtr($this->inputTemplate, ['{input}' => $input]);
         }
     }
     return parent::render($content);
 }
예제 #28
0
 /**
  * Renders a textarea.
  * @param array $options
  * @return ActiveField
  */
 public function textarea($options = [])
 {
     Html::addCssClass($options, ['textarea' => 'materialize-textarea']);
     return parent::textarea($options);
 }
예제 #29
0
 public function render($content = null)
 {
     $this->adaptField();
     $this->processPrependAndAppend();
     return parent::render($content);
 }
예제 #30
0
 /**
  * @inheritdoc
  */
 public function end()
 {
     $result = parent::end();
     return str_replace('</div', '</dl', $result);
 }