I would like to implement a solution where the field types of a form are coming from database. My form is an ActiveForm with a model.
I was adding the following to db:
formfield: textInput
and this to the form:
<?= $form->field($model, 'rgw')->{$model->rrgw->formfield}(['maxlength' => true]) ?>
this is the only way it works, and only for textinput. As soon as I delete (['maxlength' => true])
it's not working anymore and I get the error:
Getting unknown property: yii\bootstrap\ActiveField::textInput
Furthermore, if I want a checkbox or something else, (['maxlength' => true])
is not wanted, right? So I was trying to add ()
to the db, so like this:
formfield: textInput()
I'm still getting error:
Getting unknown property: yii\bootstrap\ActiveField::textInput()
How can I get rid of ()
part in yii and move this to the db? Can you please point me to the right direction? Many thanks for your help!
textInput()
and checkbox()
are methods, so you need to use ()
to indicate that you want a methods instead of property.
<?= $form->field($model, 'rgw')->{$model->rrgw->formfield}() ?>