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

help text in attribute

vwasteels opened this issue · comments

Hi,
I was wondering if it could be possible to pass help text directly through an attribute like any other parameters ?
something like this :

<x-form-input
  name="name"
  label="Name"
  help="Your name will not be visible"
/>

Thanks !!

Yes you can do that! First you need to publish the Blade views, and then you can use the $attributes variable to access the help text.

https://github.com/protonemedia/laravel-form-components#customize-the-blade-views

For example, resources/views/vendor/form-components/tailwind-2/form-input.blade.php:

<div class="@if($type === 'hidden') hidden @else mt-4 @endif">
    <label class="block">
        ...
    </label>

    @isset($attributes['help'])
        <p class="mt-4 text-orange-500">{{ $attributes['help'] }}</p>
    @endisset

    ...
</div>

ok thanks !
in the mean time I made a pull request : #30

I've closed the PR as you can do this without modifying the package (see PR).