|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wangxj
- * Date: 2017/05/16
- * Time: 16:26
- */
-
- namespace common\components;
-
- use Yii;
- use yii\widgets\ActiveForm;
- use yii\helpers\ArrayHelper;
-
- class zActiveForm extends ActiveForm
- {
- const FIELD_INPUT = 1;
-
- public $fieldClass = 'common\components\zActiveField';
- /**
- * User: wangxj
- *
- * 重写函数作用 field
- *
- * @param \yii\base\Model $model
- * @param string $attribute
- * @param array $options
- * @return zActiveField the created ActiveField object.
- */
- public function field($model, $attribute, $options = [])
- {
- $config = $this->fieldConfig;
- if ($config instanceof \Closure) {
- $config = call_user_func($config, $model, $attribute);
- }
- if (!isset($config['class'])) {
- $config['class'] = $this->fieldClass;
- }
- return Yii::createObject(ArrayHelper::merge($config, $options, [
- 'model' => $model,
- 'attribute' => $attribute,
- 'form' => $this,
- ]));
- }
-
- // public function endField()
- // {
- // $field = array_pop($this->_fields);
- // if ($field instanceof zActiveField) {
- // return $field->end();
- // } else {
- // throw new InvalidCallException('Mismatching endField() call.');
- // }
- // }
- }
|