Answer the question
In order to leave comments, you need to log in
How to validate an array of checkboxes in formbuilder (the symphony form used in laravel)?
Good afternoon!
There is a form builder (a symphony form which is used in laravel). Documentation https://kristijanhusak.github.io/laravel-form-builder/
In the "Short description(Ru)"(short_description_ru) field, an error is displayed when empty, but not in the "Interface Languages"(interfaceLangs) field. How to fix it?
$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();
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question