N
N
nulled132016-07-12 12:13:50
Yii
nulled13, 2016-07-12 12:13:50

[YII 2] How to remove model name in ActiveForm?

Good afternoon, when creating a form through ActiveForm, the field names contain the model name (name="User[login]"), is it possible to somehow remove the model name so that only the field name remains (name="login") and save the ability loading data into the model via the load() method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2016-07-12
@nulled13

Override Model::formName

public function formName()
    {
        return '';
    }

Model::load receives $formName as the second parameter, if you pass '' there, it is an example of parameter names in its pure form, or again, override the method.
Look in the source \yii\base\Model, it's all there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question