有一个formbuilder形式(laravel中使用的交响乐形式)。说明文件https://kristijanhusak.github.io/laravel-form-builder/ 如果未填写,则在“简短描述(Ru)”(short_description_ru)字段中显示错误,但在“界面语言”(interfaceLangs)字段中则未显示错误。空域name_ru存在,但是如何解决? 至少应选中一个复选框。 https://imgur.com/yNE2aVG
我尝试在reqired上更改requred_with,但是它不起作用。我不明白复选框的有效性。
$this->add("short_description_ru", "textarea", [
'label' => 'Краткое описание(Ru)',
"label_attr" => ["class" => "control-label required"],
'rules' => 'min:100|max:200',
'value' => $this->model->{'short_description:ru'} ?? '',
'wrapper' => ['class' => 'form-group col-md-12'],
'attr' => [
'id' => 'short_description_ru',
'data-redactor' => true,
'placeholder' => 'Описание должно быть не короче 100 символов',
'data-parsley-length' => '[100,200]',
'maxlength' => '200',
],
'error_messages' => [
'short_description.max' => 'Короткое описание не должно быть длинее 200 символов',
],
])->add("interfaceLangs", "entity", [
"expanded" => true,
"multiple" => true,
"class" => "App\Models\ApplicationInterfaceLang",
"property" => "label",
"label_attr" => ["class" => "control-label required"],
"rules" => "required_with:name",
"selected" => function ($langs) {
if (!$langs) {
return [];
}
return $langs->pluck("id")->toArray();
},
提交表单后,如果未选中任何复选框,则应为消息。但是现在没有。