8
8
namespace yii \widgets ;
9
9
10
10
use Yii ;
11
- use yii \base \InvalidConfigException ;
12
11
use yii \base \Widget ;
13
12
use yii \base \Model ;
14
13
use yii \helpers \Html ;
@@ -31,12 +30,6 @@ class ActiveForm extends Widget
31
30
* Defaults to 'post'.
32
31
*/
33
32
public $ method = 'post ' ;
34
- /**
35
- * @var Model the model associated with this form. This property must be set if you call [[field()]]
36
- * to create input fields. If a form is associated with multiple models, this property is not needed
37
- * and you should use [[mfield()]] to create input fields.
38
- */
39
- public $ model ;
40
33
/**
41
34
* @var array the HTML attributes (name-value pairs) for the form tag.
42
35
* The values will be HTML-encoded using [[Html::encode()]].
@@ -215,50 +208,17 @@ public function errorSummary($models, $options = array())
215
208
}
216
209
217
210
/**
218
- * Generates a form field using [[model]] and the specified attribute.
219
- *
211
+ * Generates a form field.
220
212
* A form field is associated with a model and an attribute. It contains a label, an input and an error message
221
- * and uses them to interact with end users to collect their input for the attribute.
222
- *
223
- * This method is mainly used for a form with a single model.
224
- *
225
- * @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
226
- * about attribute expression.
227
- * @param array $options the additional configurations for the field object
228
- * @return ActiveField the created ActiveField object
229
- * @throws InvalidConfigException if [[model]] is not specified
230
- * @see fieldConfig
231
- * @see mfield
232
- */
233
- public function field ($ attribute , $ options = array ())
234
- {
235
- if (!$ this ->model instanceof Model) {
236
- throw new InvalidConfigException ('The "model" property must be set. ' );
237
- }
238
- return Yii::createObject (array_merge ($ this ->fieldConfig , $ options , array (
239
- 'model ' => $ this ->model ,
240
- 'attribute ' => $ attribute ,
241
- 'form ' => $ this ,
242
- )));
243
- }
244
-
245
- /**
246
- * Generates a form field using the specified model and attribute.
247
- *
248
- * This method differs from [[field()]] in that the model is passed as a parameter rather than obtained
249
- * from [[model]].
250
- *
251
- * This method is mainly used for a form with multiple models.
252
- *
213
+ * and use them to interact with end users to collect their inputs for the attribute.
253
214
* @param Model $model the data model
254
215
* @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
255
216
* about attribute expression.
256
217
* @param array $options the additional configurations for the field object
257
218
* @return ActiveField the created ActiveField object
258
219
* @see fieldConfig
259
- * @see field
260
220
*/
261
- public function mfield ($ model , $ attribute , $ options = array ())
221
+ public function field ($ model , $ attribute , $ options = array ())
262
222
{
263
223
return Yii::createObject (array_merge ($ this ->fieldConfig , $ options , array (
264
224
'model ' => $ model ,
0 commit comments