Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Forms] Add an "Other" option to the form #480

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"field.question": "Question",
"field.recipients": "Recipients",
"field.required": "Required",
"field.enable_other": "Enable other",
"field.role": "Role",
"field.route": "Route",
"field.send_submissions": "Send submissions by email",
Expand Down
2 changes: 2 additions & 0 deletions resources/js/components/Blocks/Form/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
:help="$t('field_help.one_per_line')"
v-model="content.options"
/>

<form-switch :label="$t('field.enable_other')" v-model="content.enable_other" />
</template>

<script>
Expand Down
16 changes: 16 additions & 0 deletions resources/js/components/Form/CheckboxGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@
/>
</label>
</div>
asdasd
{{ enable_other }}
<div class="flex flex-wrap gap-4" v-if="enable_other">
<label
class="flex space-x-2"
>
<input
type="text"
name="other"
class="text-blue-600 border-gray-300 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50 my-0.5"
value=""
/>
<span
class="text-sm font-medium text-gray-700">Other</span>
</label>
</div>

<p
v-if="help"
Expand Down
11 changes: 10 additions & 1 deletion resources/views/components/blocks/form/checkbox.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@props(['block'])

<script>
console.log(@json($block));
</script>
<x-blocks.form._field :block="$block" tag="div" no-shadow>
<fieldset class="mt-3 space-y-3" x-init="initializeField([])" name="{{ $block->name }}">
@foreach ($block->options() as $option)
Expand All @@ -21,5 +23,12 @@
</label>
</div>
@endforeach

@if ($block->checkbox('enable_other'))
<div>
<label class="text-sm text-gray-700">Introduceți altceva:</label>
<input type="text" name="{$block->name}[]" value="testingvalue" class="w-full border-gray-300 focus:ring-primary">
</div>
@endif
</fieldset>
</x-blocks.form._field>