Fix form store
This commit is contained in:
parent
72177c522f
commit
48533a0737
2 changed files with 20 additions and 14 deletions
|
|
@ -9,6 +9,12 @@ use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
|||
|
||||
class StoreFormularyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* * This should be set somewhere else.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $mobileAppLocales = ['fr', 'en', 'de', 'nl'];
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
|
@ -28,7 +34,7 @@ class StoreFormularyRequest extends FormRequest
|
|||
{
|
||||
$this->merge([
|
||||
'required' => $this->required ? true : false,
|
||||
'is_visible' => $this->visible ? true : false,
|
||||
'is_visible' => $this->is_visible ? true : false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -39,20 +45,20 @@ class StoreFormularyRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
// FIXME: details has to be validated.
|
||||
|
||||
|
||||
$rules = [
|
||||
'type' => ['required', new EnumIsValidRule(InputTypeEnum::class)],
|
||||
'placeholder' => 'present|array',
|
||||
'placeholder.fr' => 'required|string|min:3|max:100',
|
||||
'placeholder.en' => 'required|string|min:3|max:100',
|
||||
'placeholder.de' => 'required|string|min:3|max:100',
|
||||
'placeholder.nl' => 'required|string|min:3|max:100',
|
||||
'details' => 'nullable|array',
|
||||
'details.*' => 'required|array',
|
||||
'details.*.*' => 'sometimes|string|min:3|max:100',
|
||||
'required' => 'required|boolean',
|
||||
'is_visible' => 'required|boolean',
|
||||
];
|
||||
foreach ($this->mobileAppLocales as $locale) {
|
||||
$rules["placeholder.{$locale}"] = 'required|string|min:3|max:100';
|
||||
$rules["details.*.{$locale}"] = 'required|string|min:3|max:100';
|
||||
}
|
||||
if (intval($this->status) !== InputStatusEnum::locked()->value) {
|
||||
$rules = array_merge($rules, ['name' => 'required|string|min:3|max:70']);
|
||||
}
|
||||
|
|
@ -66,19 +72,19 @@ class StoreFormularyRequest extends FormRequest
|
|||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
$attributes = [
|
||||
'type' => trans('type'),
|
||||
'name' => trans('nom'),
|
||||
'placeholder' => trans('placeholder'),
|
||||
'placeholder.fr' => trans('placeholder (FR)'),
|
||||
'placeholder.en' => trans('placeholder (EN)'),
|
||||
'placeholder.de' => trans('placeholder (DE) '),
|
||||
'placeholder.nl' => trans('placeholder (NL)'),
|
||||
'details' => trans('détail'),
|
||||
'details.*' => trans('détail 2'),
|
||||
'details.*.value' => trans('valeur d\'un élément dans la liste des détails du contenu'),
|
||||
'required' => trans('l\'état d\'obligation'),
|
||||
'is_visible' => trans('l\'état de visibilité'),
|
||||
];
|
||||
foreach ($this->mobileAppLocales as $locale) {
|
||||
$attributes["placeholder.{$locale}"] = trans('placeholder (:lang)', ['lang' => $locale]);
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
@change="updateVisibleValue()"
|
||||
id="fieldVisible"
|
||||
class="form-check-input"
|
||||
name="visible"
|
||||
name="is_visible"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
role="button"
|
||||
ref="inputVisible"
|
||||
:checked="(intModel?.visible) ? true : false"
|
||||
:checked="(intModel?.is_visible) ? true : false"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue