diff --git a/src/lib/Html.php b/src/lib/Html.php index 0795062..a01e1f3 100755 --- a/src/lib/Html.php +++ b/src/lib/Html.php @@ -133,80 +133,4 @@ private static function normalizeMaxLength($model, $attribute, &$options) } } } - - /** - * Generates a radio button tag together with a label for the given model attribute. - * This method will generate the "checked" tag attribute according to the model attribute value. - * @param Model $model the model object - * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format - * about attribute expression. - * @param array $options the tag options in terms of name-value pairs. - * See [[booleanInput()]] for details about accepted attributes. - * - * @return string the generated radio button tag - */ - public static function activeRadio($model, $attribute, $options = []) - { - return static::activeBooleanInput('radio', $model, $attribute, $options); - } - - /** - * Generates a checkbox tag together with a label for the given model attribute. - * This method will generate the "checked" tag attribute according to the model attribute value. - * @param Model $model the model object - * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format - * about attribute expression. - * @param array $options the tag options in terms of name-value pairs. - * See [[booleanInput()]] for details about accepted attributes. - * - * @return string the generated checkbox tag - */ - public static function activeCheckbox($model, $attribute, $options = []) - { - return static::activeBooleanInput('checkbox', $model, $attribute, $options); - } - - /** - * Generates a boolean input - * This method is mainly called by [[activeCheckbox()]] and [[activeRadio()]]. - * @param string $type the input type. This can be either `radio` or `checkbox`. - * @param Model $model the model object - * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format - * about attribute expression. - * @param array $options the tag options in terms of name-value pairs. - * See [[booleanInput()]] for details about accepted attributes. - * @return string the generated input element - * @since 2.0.9 - */ - protected static function activeBooleanInput($type, $model, $attribute, $options = []) - { - $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); - $value = static::getAttributeValue($model, $attribute); - - if (!array_key_exists('value', $options)) { - $options['value'] = '1'; - } - if (!array_key_exists('uncheck', $options)) { - $options['uncheck'] = '0'; - } elseif ($options['uncheck'] === false) { - unset($options['uncheck']); - } - if (!array_key_exists('label', $options)) { - $options['label'] = static::encode($model->getAttributeLabel(static::getAttributeName($attribute))); - } elseif ($options['label'] === false) { - unset($options['label']); - } - - if (isset($options['label'])) { - $options['label'] = '' . $options['label'] . ''; - } - - $checked = "$value" === "{$options['value']}"; - - if (!array_key_exists('id', $options)) { - $options['id'] = static::getInputId($model, $attribute); - } - - return static::$type($name, $checked, $options); - } } diff --git a/src/widgets/form/ActiveField.php b/src/widgets/form/ActiveField.php index 27425b8..65c7bd9 100755 --- a/src/widgets/form/ActiveField.php +++ b/src/widgets/form/ActiveField.php @@ -249,22 +249,12 @@ public function icon() * Materialize standard to not wrap the checkboxes in labels. * @return $this */ - public function checkbox($options = [], $enclosedByLabel = true) + public function checkbox($options = [], $enclosedByLabel = false) { Html::addCssClass($this->options, ['class' => 'checkbox']); Html::removeCssClass($this->options, 'input-field'); - $this->parts['{input}'] = Html::activeCheckbox($this->model, $this->attribute, $options); - $this->parts['{label}'] = ''; - - if ($this->form->validationStateOn === ActiveForm::VALIDATION_STATE_ON_INPUT) { - $this->addErrorClassIfNeeded($options); - } - - $this->addAriaAttributes($options); - $this->adjustLabelFor($options); - - return $this; + return parent::checkbox($options, $enclosedByLabel); } /** @@ -296,22 +286,12 @@ public function dropDownList($items, $options = []) * Materialize standard to not wrap the checkboxes in labels. * @return $this */ - public function radio($options = [], $enclosedByLabel = true) + public function radio($options = [], $enclosedByLabel = false) { Html::addCssClass($this->options, ['class' => 'radio']); Html::removeCssClass($this->options, 'input-field'); - $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options); - $this->parts['{label}'] = ''; - - if ($this->form->validationStateOn === ActiveForm::VALIDATION_STATE_ON_INPUT) { - $this->addErrorClassIfNeeded($options); - } - - $this->addAriaAttributes($options); - $this->adjustLabelFor($options); - - return $this; + return parent::radio($options, $enclosedByLabel); } /**