From 6fd1c16609a4b80dc0d46b1317ca2a19e5a7221e Mon Sep 17 00:00:00 2001
From: Qiang Xue
Date: Wed, 19 Jun 2013 19:14:41 -0400
Subject: [PATCH] Revert "Added ActiveForm::mfield()."
This reverts commit 9a5ca9951318447d050e5d53b05c0c281667b1a5.
---
apps/advanced/backend/views/site/login.php | 11 +++----
apps/advanced/frontend/views/site/contact.php | 11 +++----
apps/advanced/frontend/views/site/login.php | 11 +++----
apps/basic/views/site/contact.php | 11 +++----
apps/basic/views/site/login.php | 11 +++----
docs/guide/upgrade-from-v1.md | 6 ++--
framework/yii/widgets/ActiveForm.php | 46 ++-------------------------
7 files changed, 28 insertions(+), 79 deletions(-)
diff --git a/apps/advanced/backend/views/site/login.php b/apps/advanced/backend/views/site/login.php
index 0e2b8c6..ea9f456 100644
--- a/apps/advanced/backend/views/site/login.php
+++ b/apps/advanced/backend/views/site/login.php
@@ -14,13 +14,10 @@ $this->params['breadcrumbs'][] = $this->title;
Please fill out the following fields to login:
- $model,
- 'options' => array('class' => 'form-horizontal'),
-)); ?>
- field('username')->textInput(); ?>
- field('password')->passwordInput(); ?>
- field('rememberMe')->checkbox(); ?>
+ array('class' => 'form-horizontal'))); ?>
+ field($model, 'username')->textInput(); ?>
+ field($model, 'password')->passwordInput(); ?>
+ field($model, 'rememberMe')->checkbox(); ?>
'btn btn-primary')); ?>
diff --git a/apps/advanced/frontend/views/site/contact.php b/apps/advanced/frontend/views/site/contact.php
index 951eaa6..41e87db 100644
--- a/apps/advanced/frontend/views/site/contact.php
+++ b/apps/advanced/frontend/views/site/contact.php
@@ -24,15 +24,14 @@ $this->params['breadcrumbs'][] = $this->title;
$model,
'options' => array('class' => 'form-horizontal'),
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')),
)); ?>
- field('name')->textInput(); ?>
- field('email')->textInput(); ?>
- field('subject')->textInput(); ?>
- field('body')->textArea(array('rows' => 6)); ?>
- field('verifyCode')->widget(Captcha::className(), array(
+ field($model, 'name')->textInput(); ?>
+ field($model, 'email')->textInput(); ?>
+ field($model, 'subject')->textInput(); ?>
+ field($model, 'body')->textArea(array('rows' => 6)); ?>
+ field($model, 'verifyCode')->widget(Captcha::className(), array(
'options' => array('class' => 'input-medium'),
)); ?>
diff --git a/apps/advanced/frontend/views/site/login.php b/apps/advanced/frontend/views/site/login.php
index 0e2b8c6..ea9f456 100644
--- a/apps/advanced/frontend/views/site/login.php
+++ b/apps/advanced/frontend/views/site/login.php
@@ -14,13 +14,10 @@ $this->params['breadcrumbs'][] = $this->title;
Please fill out the following fields to login:
- $model,
- 'options' => array('class' => 'form-horizontal'),
-)); ?>
- field('username')->textInput(); ?>
- field('password')->passwordInput(); ?>
- field('rememberMe')->checkbox(); ?>
+ array('class' => 'form-horizontal'))); ?>
+ field($model, 'username')->textInput(); ?>
+ field($model, 'password')->passwordInput(); ?>
+ field($model, 'rememberMe')->checkbox(); ?>
'btn btn-primary')); ?>
diff --git a/apps/basic/views/site/contact.php b/apps/basic/views/site/contact.php
index 951eaa6..41e87db 100644
--- a/apps/basic/views/site/contact.php
+++ b/apps/basic/views/site/contact.php
@@ -24,15 +24,14 @@ $this->params['breadcrumbs'][] = $this->title;
$model,
'options' => array('class' => 'form-horizontal'),
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')),
)); ?>
- field('name')->textInput(); ?>
- field('email')->textInput(); ?>
- field('subject')->textInput(); ?>
- field('body')->textArea(array('rows' => 6)); ?>
- field('verifyCode')->widget(Captcha::className(), array(
+ field($model, 'name')->textInput(); ?>
+ field($model, 'email')->textInput(); ?>
+ field($model, 'subject')->textInput(); ?>
+ field($model, 'body')->textArea(array('rows' => 6)); ?>
+ field($model, 'verifyCode')->widget(Captcha::className(), array(
'options' => array('class' => 'input-medium'),
)); ?>
diff --git a/apps/basic/views/site/login.php b/apps/basic/views/site/login.php
index 0e2b8c6..ea9f456 100644
--- a/apps/basic/views/site/login.php
+++ b/apps/basic/views/site/login.php
@@ -14,13 +14,10 @@ $this->params['breadcrumbs'][] = $this->title;
Please fill out the following fields to login:
- $model,
- 'options' => array('class' => 'form-horizontal'),
-)); ?>
- field('username')->textInput(); ?>
- field('password')->passwordInput(); ?>
- field('rememberMe')->checkbox(); ?>
+ array('class' => 'form-horizontal'))); ?>
+ field($model, 'username')->textInput(); ?>
+ field($model, 'password')->passwordInput(); ?>
+ field($model, 'rememberMe')->checkbox(); ?>
'btn btn-primary')); ?>
diff --git a/docs/guide/upgrade-from-v1.md b/docs/guide/upgrade-from-v1.md
index bd20b91..ebfe94b 100644
--- a/docs/guide/upgrade-from-v1.md
+++ b/docs/guide/upgrade-from-v1.md
@@ -327,9 +327,9 @@ is a container consisting of a label, an input, and an error message. It is repr
as an `ActiveField` object. Using fields, you can build a form more cleanly than before:
```php
- $model)); ?>
- field('username')->textInput(); ?>
- field('password')->passwordInput(); ?>
+
+ field($model, 'username')->textInput(); ?>
+ field($model, 'password')->passwordInput(); ?>
diff --git a/framework/yii/widgets/ActiveForm.php b/framework/yii/widgets/ActiveForm.php
index 117c1a9..eb14293 100644
--- a/framework/yii/widgets/ActiveForm.php
+++ b/framework/yii/widgets/ActiveForm.php
@@ -8,7 +8,6 @@
namespace yii\widgets;
use Yii;
-use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\base\Model;
use yii\helpers\Html;
@@ -32,12 +31,6 @@ class ActiveForm extends Widget
*/
public $method = 'post';
/**
- * @var Model the model associated with this form. This property must be set if you call [[field()]]
- * to create input fields. If a form is associated with multiple models, this property is not needed
- * and you should use [[mfield()]] to create input fields.
- */
- public $model;
- /**
* @var array the HTML attributes (name-value pairs) for the form tag.
* The values will be HTML-encoded using [[Html::encode()]].
* If a value is null, the corresponding attribute will not be rendered.
@@ -215,50 +208,17 @@ class ActiveForm extends Widget
}
/**
- * Generates a form field using [[model]] and the specified attribute.
- *
+ * Generates a form field.
* A form field is associated with a model and an attribute. It contains a label, an input and an error message
- * and uses them to interact with end users to collect their input for the attribute.
- *
- * This method is mainly used for a form with a single model.
- *
- * @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
- * about attribute expression.
- * @param array $options the additional configurations for the field object
- * @return ActiveField the created ActiveField object
- * @throws InvalidConfigException if [[model]] is not specified
- * @see fieldConfig
- * @see mfield
- */
- public function field($attribute, $options = array())
- {
- if (!$this->model instanceof Model) {
- throw new InvalidConfigException('The "model" property must be set.');
- }
- return Yii::createObject(array_merge($this->fieldConfig, $options, array(
- 'model' => $this->model,
- 'attribute' => $attribute,
- 'form' => $this,
- )));
- }
-
- /**
- * Generates a form field using the specified model and attribute.
- *
- * This method differs from [[field()]] in that the model is passed as a parameter rather than obtained
- * from [[model]].
- *
- * This method is mainly used for a form with multiple models.
- *
+ * and use them to interact with end users to collect their inputs for the attribute.
* @param Model $model the data model
* @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
* about attribute expression.
* @param array $options the additional configurations for the field object
* @return ActiveField the created ActiveField object
* @see fieldConfig
- * @see field
*/
- public function mfield($model, $attribute, $options = array())
+ public function field($model, $attribute, $options = array())
{
return Yii::createObject(array_merge($this->fieldConfig, $options, array(
'model' => $model,