diff --git a/app/Http/Controllers/Front/FormController.php b/app/Http/Controllers/Front/FormController.php index c8934d01..60559201 100644 --- a/app/Http/Controllers/Front/FormController.php +++ b/app/Http/Controllers/Front/FormController.php @@ -28,7 +28,9 @@ public function submit(string $locale, FormSubmissionRequest $request, Form $for { $attributes = $request->validated(); - $data = $form->blocks + $data = $form->blocks() + ->onlyFields() + ->get() ->map(function (FormField $field) use ($attributes) { $value = $attributes[$field->name] ?? null; diff --git a/app/Http/Requests/Front/FormSubmissionRequest.php b/app/Http/Requests/Front/FormSubmissionRequest.php index f9f62058..799e09df 100644 --- a/app/Http/Requests/Front/FormSubmissionRequest.php +++ b/app/Http/Requests/Front/FormSubmissionRequest.php @@ -18,7 +18,9 @@ class FormSubmissionRequest extends BaseRequest */ public function rules(): array { - return $this->form->blocks + return $this->form->blocks() + ->onlyFields() + ->get() ->mapWithKeys(function (Block $field) { $rules = [ $field->checkbox('required') ? 'required' : 'nullable', diff --git a/app/Models/FormField.php b/app/Models/FormField.php index 4aedba27..e077c8c2 100644 --- a/app/Models/FormField.php +++ b/app/Models/FormField.php @@ -4,6 +4,7 @@ namespace App\Models; +use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Support\Collection; class FormField extends Block @@ -36,4 +37,9 @@ public function options(string $field = 'options'): Collection return collect(preg_split('/\r\n|\r|\n/', $rawOptions)) ->filter(); } + + public function scopeOnlyFields(Builder $query): Builder + { + return $query->whereNotIn('type', ['content', 'divider']); + } } diff --git a/resources/js/components/Blocks/Form/Content.vue b/resources/js/components/Blocks/Form/Content.vue new file mode 100644 index 00000000..90fc8e7e --- /dev/null +++ b/resources/js/components/Blocks/Form/Content.vue @@ -0,0 +1,25 @@ + + + diff --git a/resources/js/components/Blocks/Form/Divider.vue b/resources/js/components/Blocks/Form/Divider.vue new file mode 100644 index 00000000..8935b7de --- /dev/null +++ b/resources/js/components/Blocks/Form/Divider.vue @@ -0,0 +1,15 @@ + + + diff --git a/resources/views/components/blocks/form/content.blade.php b/resources/views/components/blocks/form/content.blade.php new file mode 100644 index 00000000..ff33e1f5 --- /dev/null +++ b/resources/views/components/blocks/form/content.blade.php @@ -0,0 +1,5 @@ + + +
+ {!! $block->translatedInput('text') !!} +
diff --git a/resources/views/components/blocks/form/divider.blade.php b/resources/views/components/blocks/form/divider.blade.php new file mode 100644 index 00000000..b0d48663 --- /dev/null +++ b/resources/views/components/blocks/form/divider.blade.php @@ -0,0 +1,7 @@ +@php + $color = $block->input('color'); +@endphp + +