Skip to content

Commit

Permalink
Make show_label available to all fieldtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Jul 24, 2021
1 parent ca9ae0a commit bb01d37
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ There are multiple configuration options for your form fields:
| `default` | `array`, `boolean`, `integer`, `string` | All fieldtypes | Set the field's default value |
| `inline` | `boolean` | `checkboxes`, `radio` | Set to `true` to display the fields inline |
| `placeholder` | `string` | `input`, `textarea` | Set the field's placeholder value |
| `show_label` | `boolean` | `checkboxes`, `radio` | Set to `false` to hide the field's label and instructions. This can be useful for single checkboxes, eg. `Accept terms and conditions`. |
| `show_label` | `boolean` | All fieldtypes | Set to `false` to hide the field's label and instructions. This can be useful for single checkboxes, eg. `Accept terms and conditions`. |
| `width` | `integer` | All fieldtypes | Set the desired width of the field. |

## Events
Expand Down
12 changes: 8 additions & 4 deletions resources/views/antlers/fields/input.antlers.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<label for="{{ handle ?? fields[field].handle }}" class="block text-sm font-medium text-gray-700">
{{ label ?? fields[field].label }}
</label>
{{ if show_label ?? fields[field].show_label }}
<div class="mb-1">
<label for="{{ handle ?? fields[field].handle }}" class="block text-sm font-medium text-gray-700">
{{ label ?? fields[field].label }}
</label>
</div>
{{ /if }}

<div class="mt-1">
<div>
<input
id="{{ handle ?? fields[field].handle }}"
name="{{ handle ?? fields[field].handle }}"
Expand Down
15 changes: 11 additions & 4 deletions resources/views/antlers/fields/select.antlers.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<label for="{{ handle ?? fields[field].handle }}" class="block text-sm font-medium text-gray-700">
{{ label ?? fields[field].label }}
</label>
{{ if show_label ?? fields[field].show_label }}
<div class="mb-1">
<label for="{{ handle ?? fields[field].handle }}" class="block font-medium text-gray-700 {{ instructions || fields[field].instructions ? 'text-base' : 'text-sm' }}">
{{ label ?? fields[field].label }}
</label>
{{ if instructions || fields[field].instructions }}
<p class="mb-4 text-sm text-gray-500">{{ instructions ?? fields[field].instructions }}</p>
{{ /if }}
</div>
{{ /if }}

<div class="mt-1">
<div>
<select
id="{{ handle ?? fields[field].handle }}"
name="{{ handle ?? fields[field].handle }}"
Expand Down
12 changes: 8 additions & 4 deletions resources/views/antlers/fields/textarea.antlers.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<label for="{{ handle ?? fields[field].handle }}" class="block text-sm font-medium text-gray-700">
{{ label ?? fields[field].label }}
</label>
{{ if show_label ?? fields[field].show_label }}
<div class="mb-1">
<label for="{{ handle ?? fields[field].handle }}" class="block text-sm font-medium text-gray-700">
{{ label ?? fields[field].label }}
</label>
</div>
{{ /if }}

<div class="mt-1">
<div>
<textarea
id="{{ handle ?? fields[field].handle }}"
name="{{ handle ?? fields[field].handle }}"
Expand Down
12 changes: 8 additions & 4 deletions resources/views/blade/fields/input.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<label for="{{ $field['handle'] }}" class="block text-sm font-medium text-gray-700">
{{ $field['label'] }}
</label>
@if ($field['show_label'])
<div class="mb-1">
<label for="{{ $field['handle'] }}" class="block text-sm font-medium text-gray-700">
{{ $field['label'] }}
</label>
</div>
@endif

<div class="mt-1">
<div>
<input
id="{{ $field['handle'] }}"
name="{{ $field['handle'] }}"
Expand Down
15 changes: 11 additions & 4 deletions resources/views/blade/fields/select.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<label for="{{ $field['handle'] }}" class="block text-sm font-medium text-gray-700">
{{ $field['label'] }}
</label>
@if ($field['show_label'])
<div class="mb-1">
<label for="{{ $field['handle'] }}" class="block font-medium text-gray-700 @if ($field['instructions']) text-base @else text-sm @endif">
{{ $field['label'] }}
</label>
@if ($field['instructions'])
<p class="mb-4 text-sm text-gray-500">{{ $field['instructions'] }}</p>
@endif
</div>
@endif

<div class="mt-1">
<div>
<select
id="{{ $field['handle'] }}"
name="{{ $field['handle'] }}"
Expand Down
12 changes: 8 additions & 4 deletions resources/views/blade/fields/textarea.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<label for="{{ $field['handle'] }}" class="block text-sm font-medium text-gray-700">
{{ $field['label'] }}
</label>
@if ($field['show_label'])
<div class="mb-1">
<label for="{{ $field['handle'] }}" class="block text-sm font-medium text-gray-700">
{{ $field['label'] }}
</label>
</div>
@endif

<div class="mt-1">
<div>
<textarea
id="{{ $field['handle'] }}"
name="{{ $field['handle'] }}"
Expand Down

0 comments on commit bb01d37

Please sign in to comment.