Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 9b0717b

Browse files
committed
Better use of $attributes and minor fixes
1 parent 64ffe1d commit 9b0717b

16 files changed

+72
-43
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to `laravel-form-components` will be documented in this file
44

5+
## 1.0.1 - 2020-07-18
6+
7+
- added `hasErrorAndShow` method to components
8+
- use `$slot` and added `$attributes` to `form-button`
9+
- added `$attibutes` to `form-group` and `form-label`
10+
- fixed translation bug
11+
512
## 1.0.0 - 2020-07-17
613

714
- initial release

resources/views/tailwind/form-checkbox.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<span class="ml-2">{{ $label }}</span>
1414
</label>
1515

16-
@if($showErrors)
16+
@if($hasErrorAndShow($name))
1717
<x-form-errors :name="$name" />
1818
@endif
1919
</div>
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
@if($name)
2-
@error($name)
3-
<p {!! $attributes->merge(['class' => 'text-red-500 text-xs italic']) !!}>
4-
{{ $message }}
5-
</p>
6-
@enderror
7-
@endif
1+
@error($name)
2+
<p {!! $attributes->merge(['class' => 'text-red-500 text-xs italic']) !!}>
3+
{{ $message }}
4+
</p>
5+
@enderror
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<div class="mt-4">
1+
<div {!! $attributes->merge(['class' => 'mt-4']) !!}>
22
<x-form-label :label="$label" />
33

44
<div class="@if($label) mt-2 @endif @if($inline) flex flex-wrap space-x-6 @endif">
55
{!! $slot !!}
66
</div>
77

8-
@if($showErrors)
8+
@if($hasErrorAndShow($name))
99
<x-form-errors :name="$name" />
1010
@endif
1111
</div>

resources/views/tailwind/form-input.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/>
1212
</label>
1313

14-
@if($showErrors)
14+
@if($hasErrorAndShow($name))
1515
<x-form-errors :name="$name" />
1616
@endif
1717
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@if($label)
2-
<span class="text-gray-700">{{ $label }}</span>
2+
<span {!! $attributes->merge(['class' => 'text-gray-700']) !!}>{{ $label }}</span>
33
@endif

resources/views/tailwind/form-radio.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<span class="ml-2">{{ $label }}</span>
1414
</label>
1515

16-
@if($showErrors)
16+
@if($hasErrorAndShow($name))
1717
<x-form-errors :name="$name" />
1818
@endif
1919
</div>

resources/views/tailwind/form-select.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</select>
1919
</label>
2020

21-
@if($showErrors)
21+
@if($hasErrorAndShow($name))
2222
<x-form-errors :name="$name" />
2323
@endif
2424
</div>
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<div class="mt-6 flex items-center justify-between">
2-
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" type="submit">
3-
{{ $label }}
2+
<button {!! $attributes->merge([
3+
'class' => 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline',
4+
'type' => 'submit'
5+
]) !!}>
6+
{!! trim($slot) ?: __('Submit') !!}
47
</button>
58
</div>

resources/views/tailwind/form-textarea.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name="{{ $name }}">{!! $value !!}</textarea>
99
</label>
1010

11-
@if($showErrors)
11+
@if($hasErrorAndShow($name))
1212
<x-form-errors :name="$name" />
1313
@endif
1414
</div>

0 commit comments

Comments
 (0)