1 year ago

Enable/disable required policy from the Laravel Boilerplate forms dynamically.

Posted 1 year ago by ravasaurio

Hi. I have added some new fields to the Laravel Boilerplate user creation form. Those fields will only display if a certain role is selected when creating a new user. I want those fields to be required, but then when you don't see them, it will not let you send the form because those fields are empty. How can I set those fields required only when they are visible? I've never seen a form like this before:

{{ html()->label(__('validation.attributes.backend.access.users.last_name'))->class('col-md-2 form-control-label')->for('last_name') }}
                        <div class="col-md-10">
                            {{ html()->text('last_name')
                                ->attribute('maxlength', 191)
                                ->required()  //<-enable/disable this}}

Please sign in or create an account to participate in this conversation.