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!

Home Page:https://protone.media/blog/laravel-form-components-to-rapidly-build-forms-with-tailwind-css-and-bootstrap-4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

disabled / required attributes passed with Blade

supergreentony opened this issue · comments

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!

<x-form-input name="client_name" label="Name *" :required="$clientIsDisabled" />