mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Minor refacotring of bootstrap active field and form.
This commit is contained in:
@ -62,7 +62,7 @@ use yii\helpers\ArrayHelper;
|
||||
* ]
|
||||
* ]);
|
||||
*
|
||||
* // With standard layout you would use 'template' to size a specific field:
|
||||
* // With 'default' layout you would use 'template' to size a specific field:
|
||||
* // echo $form->field($model, 'demo', [
|
||||
* // 'template' => '{label} <div class="row"><div class="col-sm-4">{input}{error}{hint}</div></div>'
|
||||
* // ]);
|
||||
@ -84,12 +84,12 @@ use yii\helpers\ArrayHelper;
|
||||
class ActiveField extends \yii\widgets\ActiveField
|
||||
{
|
||||
/**
|
||||
* @var bool whether to render [[checkboxList()]] and [[radioList()]] inline. Default is `false`.
|
||||
* @var bool whether to render [[checkboxList()]] and [[radioList()]] inline.
|
||||
*/
|
||||
public $inline = false;
|
||||
|
||||
/**
|
||||
* @var string|null optional template to render the `{input}` placheolder content
|
||||
* @var string|null optional template to render the `{input}` placeholder content
|
||||
*/
|
||||
public $inputTemplate;
|
||||
|
||||
@ -119,7 +119,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
public $enableLabel = true;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
@ -129,7 +129,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function render($content = null)
|
||||
{
|
||||
@ -161,7 +161,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function checkbox($options = [], $enclosedByLabel = true)
|
||||
{
|
||||
@ -182,7 +182,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function checkboxList($items, $options = [])
|
||||
{
|
||||
@ -202,7 +202,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function radioList($items, $options = [])
|
||||
{
|
||||
@ -222,7 +222,7 @@ class ActiveField extends \yii\widgets\ActiveField
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function label($label = null, $options = [])
|
||||
{
|
||||
|
||||
@ -7,10 +7,9 @@
|
||||
|
||||
namespace yii\bootstrap;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
use yii\base\InvalidConfigException;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* A Bootstrap 3 enhanced version of [[yii\widgets\ActiveForm]].
|
||||
@ -73,29 +72,29 @@ class ActiveForm extends \yii\widgets\ActiveForm
|
||||
public $options = ['role' => 'form'];
|
||||
|
||||
/**
|
||||
* @var string the form layout. Either 'standard' (default), 'horizontal' or 'inline'.
|
||||
* By chosing a layout, an appropriate default field configuration is applied. This will
|
||||
* @var string the form layout. Either 'default', 'horizontal' or 'inline'.
|
||||
* By choosing a layout, an appropriate default field configuration is applied. This will
|
||||
* render the form fields with slightly different markup for each layout. You can
|
||||
* override these defaults through [[fieldConfig]].
|
||||
* @see \yii\bootstrap\ActiveField for details on Bootstrap 3 field configuration
|
||||
*/
|
||||
public $layout = 'standard';
|
||||
public $layout = 'default';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!in_array($this->layout, ['standard','horizontal','inline'])) {
|
||||
if (!in_array($this->layout, ['default', 'horizontal', 'inline'])) {
|
||||
throw new InvalidConfigException('Invalid layout type: ' . $this->layout);
|
||||
}
|
||||
|
||||
if ($this->layout!=='standard') {
|
||||
if ($this->layout !== 'default') {
|
||||
Html::addCssClass($this->options, 'form-' . $this->layout);
|
||||
}
|
||||
if (!isset($this->fieldConfig['class'])) {
|
||||
$this->fieldConfig['class'] = ActiveField::className();
|
||||
}
|
||||
return parent::init();
|
||||
parent::init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ Yii Framework 2 bootstrap extension Change Log
|
||||
2.0.0 beta under development
|
||||
----------------------------
|
||||
|
||||
- Enh #3029: Added `ActiveForm` and `ActiveField` (mikehaertl)
|
||||
- Bug #2361: `yii\bootstrap\NavBar::brandUrl` should default to the home URL of application (qiangxue)
|
||||
- Enh #1474: Added option to make NavBar 100% width (cebe)
|
||||
- Enh #1552: It is now possible to use multiple bootstrap NavBar in a single page (Alex-Code)
|
||||
@ -17,6 +16,7 @@ Yii Framework 2 bootstrap extension Change Log
|
||||
- Enh #2643: Add size attribute to Modal (tof06)
|
||||
- Chg #1459: Update Collapse to use bootstrap 3 classes (tonydspaniard)
|
||||
- Chg #1820: Update Progress to use bootstrap 3 markup (samdark)
|
||||
- New #3029: Added `yii\bootstrap\ActiveForm` and `yii\bootstrap\ActiveField` (mikehaertl)
|
||||
|
||||
2.0.0-alpha, December 1, 2013
|
||||
-----------------------------
|
||||
|
||||
@ -294,6 +294,7 @@ Yii Framework 2 Change Log
|
||||
- New #2360: Added `AttributeBehavior` and `BlameableBehavior`, and renamed `AutoTimestamp` to `TimestampBehavior` (lucianobaraglia, qiangxue)
|
||||
- New #2932: Added `yii\web\ViewAction` that allow you to render views based on GET parameter (samdark)
|
||||
- New #2998: Added `framework\log\SyslogTarget` that is able to write log to syslog (miramir, samdark)
|
||||
- New #3029: Added `yii\bootstrap\ActiveForm` and `yii\bootstrap\ActiveField` (mikehaertl)
|
||||
- New: Yii framework now comes with core messages in multiple languages
|
||||
- New: Added `yii\codeception\DbTestCase` (qiangxue)
|
||||
- New: Added `yii\web\GroupUrlRule` (qiangxue)
|
||||
|
||||
Reference in New Issue
Block a user