protonemedia / laravel-form-components

A set of Blade components to rapidly build forms with Tailwind CSS (v1.0 and v2.0) and Bootstrap 4/5. Supports validation, model binding, default values, translations, Laravel Livewire, includes default vendor styling and fully customizable!
https://protone.media/blog/laravel-form-components-to-rapidly-build-forms-with-tailwind-css-and-bootstrap-4
MIT License
814 stars 104 forks source link

disabled / required attributes passed with Blade #80

Closed supergreentony closed 2 years ago

supergreentony commented 2 years ago

Hy!

I wonder how can I specify with Blade a "disabled" attribute to the component

In my case, clients can be prevent from updating by the admin For example, if I do

//$clientIsDisabled='disabled'
<x-form-input name="client_name" label="Name *" required {{ $clientIsDisabled }} />

The input is not rendered

Actually, I do something like this:

@if($clientIsDisabled)
    <x-form-input name="client_name" label="Name *" required disabled />
@else
    <x-form-input name="client_name" label="Name *" />
@endif

But it's ugly... Do not use the component in that case is maybe the simplest solution?

Do I miss something? How do you do in that situation?

Thank you!

pascalbaljet commented 2 years ago
<x-form-input name="client_name" label="Name *" :required="$clientIsDisabled" />