diff --git a/resources/views/form/submit.blade.php b/resources/views/form/submit.blade.php index 2d1d03f0..b46fbb21 100644 --- a/resources/views/form/submit.blade.php +++ b/resources/views/form/submit.blade.php @@ -1,29 +1,31 @@ @php $customStyling = $hasCustomStyling($attributes) @endphp - \ No newline at end of file + + {{ $label }} + + + @endif + + diff --git a/src/Components/Form/Submit.php b/src/Components/Form/Submit.php index ca29f858..35ddec6c 100644 --- a/src/Components/Form/Submit.php +++ b/src/Components/Form/Submit.php @@ -27,6 +27,7 @@ public function __construct( public $value = null, public $danger = false, public $secondary = false, + public string $wrapperClass = '', ) { $this->primary = !$this->danger && !$this->secondary; } diff --git a/src/FormBuilder/Button.php b/src/FormBuilder/Button.php index 2c40a105..30208a86 100644 --- a/src/FormBuilder/Button.php +++ b/src/FormBuilder/Button.php @@ -2,6 +2,7 @@ namespace ProtoneMedia\Splade\FormBuilder; +use Illuminate\Support\Arr; use ProtoneMedia\Splade\Components\Form\Submit as SpladeSubmit; use ProtoneMedia\Splade\FormBuilder\Concerns\HasValue; @@ -11,6 +12,8 @@ class Button extends Component protected bool $danger = false; + protected string $wrapperClass = ''; + protected bool $secondary = false; protected bool $spinner = true; @@ -18,7 +21,7 @@ class Button extends Component protected string $type = 'button'; /** - * Applies danger-styling to the button + * Applies danger-styling to the button. * * @return $this */ @@ -30,9 +33,23 @@ public function danger(bool $danger = true): self } /** - * Applies secondary-styling to the button + * Add one or more classes to the fields' wrapper. + * + * @param array|string $classes + * @return $this + */ + public function wrapperClass(...$classes): self + { + $classes = Arr::flatten($classes); + + $this->wrapperClass = Arr::toCssClasses($classes); + + return $this; + } + + /** + * Applies secondary-styling to the button. * - * @param bool $danger * @return $this */ public function secondary(bool $secondary = true): self @@ -56,7 +73,8 @@ public function toSpladeComponent() name: $this->name, value: $this->value ?? null, danger: $this->danger, - secondary: $this->secondary + secondary: $this->secondary, + wrapperClass: $this->wrapperClass ); } }