Add default required for field

This commit is contained in:
philipp lang 2024-04-12 15:23:18 +02:00
parent ab7e20becd
commit 1509efd881
10 changed files with 11 additions and 12 deletions

View File

@ -21,7 +21,7 @@ class CheckboxField extends Field
{
return [
['key' => 'description', 'default' => '', 'rules' => ['description' => 'required|string'], 'label' => 'Beschreibung'],
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
];
}

View File

@ -24,7 +24,7 @@ class DateField extends Field
public static function meta(): array
{
return [
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'max_today', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Nur daten bis heute erlauben'],
];
}

View File

@ -22,7 +22,7 @@ class DropdownField extends Field
{
return [
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'string'], 'label' => 'Optionen'],
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
];
}

View File

@ -147,7 +147,6 @@ abstract class Field extends Data
'type' => static::type(),
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
'value' => static::default(),
'required' => false,
'nami_type' => null,
'for_members' => true,
'special_type' => null,

View File

@ -25,7 +25,7 @@ class GroupField extends Field
public static function meta(): array
{
return [
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'parent_field', 'default' => null, 'rules' => ['parent_field' => 'present|nullable|string'], 'label' => 'Übergeordnetes Feld'],
['key' => 'parent_group', 'default' => null, 'rules' => ['parent_group' => ['present', 'nullable', Rule::in(Group::pluck('id')->toArray())]], 'label' => 'Übergeordnete Gruppierung'],
];

View File

@ -23,7 +23,7 @@ class RadioField extends Field
{
return [
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
];
}

View File

@ -19,7 +19,7 @@ class TextField extends Field
public static function meta(): array
{
return [
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
];
}

View File

@ -20,7 +20,7 @@ class TextareaField extends Field
{
return [
['key' => 'rows', 'default' => 5, 'rules' => ['rows' => 'present|integer|gt:0'], 'label' => 'Zeilen'],
['key' => 'required', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
];
}

@ -1 +1 @@
Subproject commit 7ae37c224e7579978874117436ce78c447d6ef52
Subproject commit bc45e0cdf792158372b0f12db8739c19beda1a4f

View File

@ -38,12 +38,12 @@ class FormtemplateIndexActionTest extends TestCase
'type' => 'DropdownField',
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
'value' => null,
'required' => false,
'nami_type' => null,
'for_members' => true,
'special_type' => null,
'hint' => '',
'options' => [],
'required' => true,
]
])
->assertInertiaPath('data.meta.fields.7', [
@ -54,11 +54,11 @@ class FormtemplateIndexActionTest extends TestCase
'type' => 'TextField',
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
'value' => '',
'required' => false,
'nami_type' => null,
'for_members' => true,
'special_type' => null,
'hint' => '',
'required' => true,
]
])
->assertInertiaPath('data.meta.fields.8', [
@ -69,12 +69,12 @@ class FormtemplateIndexActionTest extends TestCase
'type' => 'TextareaField',
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
'value' => '',
'required' => false,
'nami_type' => null,
'for_members' => true,
'special_type' => null,
'hint' => '',
'rows' => 5,
'required' => true,
]
])
->assertInertiaPath('data.meta.default', [