diff --git a/resources/views/components/error.blade.php b/resources/views/components/error.blade.php index db5afb5..78cdbce 100644 --- a/resources/views/components/error.blade.php +++ b/resources/views/components/error.blade.php @@ -1,5 +1,5 @@ @props(['for']) -@error($for) +@error($for->getName())

{{ $message }}

@enderror diff --git a/resources/views/components/fields/forms/boolean.blade.php b/resources/views/components/fields/forms/boolean.blade.php index a52b57e..c533907 100644 --- a/resources/views/components/fields/forms/boolean.blade.php +++ b/resources/views/components/fields/forms/boolean.blade.php @@ -10,7 +10,7 @@ {{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) ? 'checked' : '' }} name="{{ $field->getName() }}" type="checkbox"> - + diff --git a/resources/views/components/fields/forms/color.blade.php b/resources/views/components/fields/forms/color.blade.php index 2697871..47156b9 100644 --- a/resources/views/components/fields/forms/color.blade.php +++ b/resources/views/components/fields/forms/color.blade.php @@ -14,7 +14,7 @@ @endforeach - + diff --git a/resources/views/components/fields/forms/date.blade.php b/resources/views/components/fields/forms/date.blade.php index 6f4b80b..ed73bcf 100644 --- a/resources/views/components/fields/forms/date.blade.php +++ b/resources/views/components/fields/forms/date.blade.php @@ -5,10 +5,12 @@
getRequired() ? 'required' : '' }} name="{{ $field->getName() }}" type="date"> - + +
diff --git a/resources/views/components/fields/forms/input.blade.php b/resources/views/components/fields/forms/input.blade.php index c2e02be..d7e14d5 100644 --- a/resources/views/components/fields/forms/input.blade.php +++ b/resources/views/components/fields/forms/input.blade.php @@ -9,7 +9,8 @@ value="{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }}" {{ $field->getRequired() ? 'required' : '' }} name="{{ $field->getName() }}" type="{{ $field->getType() }}"> - + + diff --git a/resources/views/components/fields/forms/select.blade.php b/resources/views/components/fields/forms/select.blade.php index 227a994..f6d2b88 100644 --- a/resources/views/components/fields/forms/select.blade.php +++ b/resources/views/components/fields/forms/select.blade.php @@ -21,7 +21,8 @@ - + + diff --git a/resources/views/components/fields/forms/textarea.blade.php b/resources/views/components/fields/forms/textarea.blade.php index 6ee4c59..47e273b 100644 --- a/resources/views/components/fields/forms/textarea.blade.php +++ b/resources/views/components/fields/forms/textarea.blade.php @@ -9,7 +9,8 @@ id="{{ $field->getName() }}" name="{{ $field->getName() }}">{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }} - + + diff --git a/resources/views/components/helper-text.blade.php b/resources/views/components/helper-text.blade.php new file mode 100644 index 0000000..e5d7193 --- /dev/null +++ b/resources/views/components/helper-text.blade.php @@ -0,0 +1,5 @@ +@props(['for']) + +@if($for->getHelperText()) +

{{ $for->getHelperText() }}

+@enderror diff --git a/src/Contracts/NebulaField.php b/src/Contracts/NebulaField.php index a2a32e5..dbf82a5 100644 --- a/src/Contracts/NebulaField.php +++ b/src/Contracts/NebulaField.php @@ -82,7 +82,7 @@ public function value($value): self * Set the required property. * * @param bool $required - * @return NebulaField + * @return $this */ public function required(bool $required = true): self { @@ -95,7 +95,7 @@ public function required(bool $required = true): self * Set the rules. * * @param mixed $rules - * @return NebulaField + * @return $this */ public function rules($rules): self { diff --git a/src/Fields/BooleanField.php b/src/Fields/BooleanField.php index a0457fb..8a419c8 100644 --- a/src/Fields/BooleanField.php +++ b/src/Fields/BooleanField.php @@ -10,7 +10,7 @@ class BooleanField extends NebulaField protected string $false = 'False'; /** - * Set the true label + * Set the true label. * * @param string $label * @return $this @@ -23,7 +23,7 @@ public function true(string $label): self } /** - * Set the false label + * Set the false label. * * @param string $label * @return $this diff --git a/src/Fields/ColorField.php b/src/Fields/ColorField.php index e9f827b..dfe6e39 100644 --- a/src/Fields/ColorField.php +++ b/src/Fields/ColorField.php @@ -22,7 +22,7 @@ class ColorField extends NebulaField * Sets the colors. * * @param array $colors - * @return ColorField + * @return $this */ public function colors(array $colors): self { diff --git a/src/Fields/Concerns/HasHelperText.php b/src/Fields/Concerns/HasHelperText.php new file mode 100644 index 0000000..8760b08 --- /dev/null +++ b/src/Fields/Concerns/HasHelperText.php @@ -0,0 +1,31 @@ +helperText = $helperText; + + return $this; + } + + /** + * Returns the helper text. + * + * @return string + */ + public function getHelperText(): string + { + return $this->helperText; + } +} diff --git a/src/Fields/Concerns/HasPlaceholder.php b/src/Fields/Concerns/HasPlaceholder.php index 4d64d5f..e598270 100644 --- a/src/Fields/Concerns/HasPlaceholder.php +++ b/src/Fields/Concerns/HasPlaceholder.php @@ -10,7 +10,7 @@ trait HasPlaceholder * Sets the placeholder property. * * @param string $placeholder - * @return HasPlaceholder + * @return $this */ public function placeholder(string $placeholder): self { diff --git a/src/Fields/DateField.php b/src/Fields/DateField.php index 373523e..4a32a7f 100644 --- a/src/Fields/DateField.php +++ b/src/Fields/DateField.php @@ -5,9 +5,12 @@ use Carbon\Carbon; use Carbon\Exceptions\InvalidFormatException; use Larsklopstra\Nebula\Contracts\NebulaField; +use Larsklopstra\Nebula\Fields\Concerns\HasHelperText; class DateField extends NebulaField { + use HasHelperText; + protected string $format = 'Y-m-d'; /** @@ -26,7 +29,7 @@ public function applyFormat($date) * Applies the date format in the front-end. * * @param string $format - * @return DateField + * @return $this */ public function format(string $format): self { diff --git a/src/Fields/InputField.php b/src/Fields/InputField.php index 53a73bb..749b89f 100644 --- a/src/Fields/InputField.php +++ b/src/Fields/InputField.php @@ -3,11 +3,12 @@ namespace Larsklopstra\Nebula\Fields; use Larsklopstra\Nebula\Contracts\NebulaField; +use Larsklopstra\Nebula\Fields\Concerns\HasHelperText; use Larsklopstra\Nebula\Fields\Concerns\HasPlaceholder; class InputField extends NebulaField { - use HasPlaceholder; + use HasPlaceholder, HasHelperText; protected string $type = 'text'; @@ -15,7 +16,7 @@ class InputField extends NebulaField * Sets the HTML input type. * * @param mixed $type - * @return InputField + * @return $this */ public function type($type): self { diff --git a/src/Fields/SelectField.php b/src/Fields/SelectField.php index 94ccabc..0789c2a 100644 --- a/src/Fields/SelectField.php +++ b/src/Fields/SelectField.php @@ -3,9 +3,12 @@ namespace Larsklopstra\Nebula\Fields; use Larsklopstra\Nebula\Contracts\NebulaField; +use Larsklopstra\Nebula\Fields\Concerns\HasHelperText; class SelectField extends NebulaField { + use HasHelperText; + protected array $options = []; /** diff --git a/src/Fields/TextareaField.php b/src/Fields/TextareaField.php index b56aaa9..f1e4593 100644 --- a/src/Fields/TextareaField.php +++ b/src/Fields/TextareaField.php @@ -3,9 +3,10 @@ namespace Larsklopstra\Nebula\Fields; use Larsklopstra\Nebula\Contracts\NebulaField; +use Larsklopstra\Nebula\Fields\Concerns\HasHelperText; use Larsklopstra\Nebula\Fields\Concerns\HasPlaceholder; class TextareaField extends NebulaField { - use HasPlaceholder; + use HasPlaceholder, HasHelperText; }