我对Kartik/DepDrop
有疑问。我过去曾多次使用它,但现在有问题
我的观点
'contentBefore'=>'<legend class="text-info"><small>Client Info</small></legend>',
'attributes'=>[ // 2 column layout
'model'=>['type'=>Form::INPUT_DROPDOWN_LIST, 'items'=>ArrayHelper::map(\app\models\Models::find()->All(), 'id','name'), 'options'=>['prompt'=>'Please Select..','id'=>'model']],
'field'=>[
'type'=>Form::INPUT_WIDGET,
'widgetClass'=>DepDrop::classname(),
'options' => ['id'=>'field'],
'pluginOptions' => [
'depends' => ['model'],
'placeholder' => 'select ...',
'url' => Url::to(['dd-field'])
],
],
'related_value'=>['type'=>Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter Value...']],
]
错误显示了这个
_form.php at line 49 – yii\base\Widget::widget(['model' => app\models\RelatedFields, 'form' => kartik\form\ActiveForm, 'autoGenerateColumns' => true, 'rows' => [['contentBefore' => '<legend class="text-info"><small...', 'attributes' => ['model' => ['type' => 'dropdownList', 'items' => [1 => 'Clients', 2 => 'InvoiceItems', 3 => 'Invoices', 4 => 'Notes', ...], 'options' => ['prompt' => 'Please Select..', 'id' => 'model']], 'field' => ['type' => 'widget', 'widgetClass' => 'kartik\depdrop\DepDrop', 'options' => ['id' => 'field'], 'pluginOptions' => ['depends' => ['model'], 'placeholder' => 'select ...', 'url' => '/related-fields/dd-field']], 'related_value' => ['type' => 'textInput', 'options' => ['placeholder' => 'Enter Value...']]]], ['attributes' => ['actions' => ['type' => 'raw', 'value' => '<div style="text-align: right; m...']]]], ...])
如果你看一下它正在传递的插件选项
'pluginOptions' => ['depends' => ['model'], 'placeholder' => 'select ...', 'url' => '/related-fields/dd-field']
任何人的想法。
答案 0 :(得分:0)
发现问题,因为我正在使用FormGrid
,pluginOptions
和htmlOptions
都需要在这样的选项数组中
'field'=>[
'type'=>Form::INPUT_WIDGET,
'widgetClass'=>DepDrop::classname(),
'options' => [
'options'=> ['id' => 'field'],
'pluginOptions' => [
'depends' => ['model'],
'placeholder' => 'select ...',
'url' => '/related-fields/dd-field'
],
],
],