Php 如何解决“问题”;“获取未知财产”;在Yi2中使用DB中的表单字段时出错?

Php 如何解决“问题”;“获取未知财产”;在Yi2中使用DB中的表单字段时出错?,php,yii2,active-form,form-fields,Php,Yii2,Active Form,Form Fields,我想实现一个解决方案,其中表单的字段类型来自数据库 我的表单是一个带有模型的ActiveForm 我将以下内容添加到DB中: formfield: textInput 该表格如下: <?= $form->field($model, 'rgw')->{$model->rrgw->formfield}(['maxlength' => true]) ?> 我仍然得到错误: 获取未知属性:yii\bootstrap\ActiveField::textInpu

我想实现一个解决方案,其中表单的字段类型来自数据库

我的表单是一个带有模型的
ActiveForm

我将以下内容添加到DB中:

formfield: textInput
该表格如下:

<?= $form->field($model, 'rgw')->{$model->rrgw->formfield}(['maxlength' => true]) ?>
我仍然得到错误:

获取未知属性:yii\bootstrap\ActiveField::textInput()

如何摆脱Yii中的
()
部分并将其移动到DB中?

textInput()
checkbox()
都是方法,因此您需要使用
()
来指示您想要的是方法而不是属性

<?= $form->field($model, 'rgw')->{$model->rrgw->formfield}() ?>

,因为
()
将被解释为属性名称的一部分。因此,您正在查找
textInput()
属性而不是
textInput
method.ok,那么我如何处理例如
['maxlength'=>true]
或任何其他选项呢?因为这种方式似乎不起作用:
$form->field($model,'rgw')->{$model->rrgw->formfield}($model->rrgw->ffoption)
?或者如果我想要一个小部件?
<?= $form->field($model, 'rgw')->{$model->rrgw->formfield}() ?>