From 309415f186e92365bce49daafeb902a5d4dead1b Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 4 Sep 2014 14:36:30 -0400 Subject: [PATCH 1/2] Fixes #3910: Removed the `container` option from `Html::checkbox()` and `Html::radio()` --- ActiveField.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ActiveField.php b/ActiveField.php index 75890b2..35e1db8 100644 --- a/ActiveField.php +++ b/ActiveField.php @@ -248,10 +248,13 @@ class ActiveField extends \yii\widgets\ActiveField } if (!isset($options['itemOptions'])) { $options['itemOptions'] = [ - 'container' => false, 'labelOptions' => ['class' => 'checkbox-inline'], ]; } + } elseif (!isset($options['item'])) { + $options['item'] = function ($index, $label, $name, $checked, $value) { + return '
' . Html::checkbox($name, $checked, ['label' => $label, 'value' => $value]) . '
'; + }; } parent::checkboxList($items, $options); return $this; @@ -271,10 +274,13 @@ class ActiveField extends \yii\widgets\ActiveField } if (!isset($options['itemOptions'])) { $options['itemOptions'] = [ - 'container' => false, 'labelOptions' => ['class' => 'radio-inline'], ]; } + } elseif (!isset($options['item'])) { + $options['item'] = function ($index, $label, $name, $checked, $value) { + return '
' . Html::radio($name, $checked, ['label' => $label, 'value' => $value]) . '
'; + }; } parent::radioList($items, $options); return $this; From a3ab453aa0d5e0b493207928ea220e83a6a0ae69 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 5 Sep 2014 13:37:52 -0400 Subject: [PATCH 2/2] Fixes #3240: Added support for assigning an anonymous function to `yii\widgets\ActiveForm::fieldConfig` --- ActiveForm.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ActiveForm.php b/ActiveForm.php index b034a00..9ff20d7 100644 --- a/ActiveForm.php +++ b/ActiveForm.php @@ -66,6 +66,11 @@ use yii\base\InvalidConfigException; class ActiveForm extends \yii\widgets\ActiveForm { /** + * @var string the default field class name when calling [[field()]] to create a new field. + * @see fieldConfig + */ + public $fieldClass = 'yii\bootstrap\ActiveField'; + /** * @var array HTML attributes for the form tag. Default is `['role' => 'form']`. */ public $options = ['role' => 'form']; @@ -91,9 +96,6 @@ class ActiveForm extends \yii\widgets\ActiveForm if ($this->layout !== 'default') { Html::addCssClass($this->options, 'form-' . $this->layout); } - if (!isset($this->fieldConfig['class'])) { - $this->fieldConfig['class'] = ActiveField::className(); - } parent::init(); } }