retrograde
retrograde

Reputation: 2979

Define HTML validation attributes with Laravel Blade syntax

I would like to combine the Laravel model binding properties with the easy jQuery Validation plugin, if that is possible.

I can't figure out how to add the 'required' attribute to the blade syntax.

Here is normal form syntax with the "required" attribute:

<input type="text" name="title" required>

Laravel Blade syntax

{{ Form:: text('title', null, array('class' => 'form-control')) }}

Any help would be appreciated.

Upvotes: 1

Views: 1936

Answers (1)

Tomas Buteler
Tomas Buteler

Reputation: 4137

required is a normal HTML input attribute. The only difference is that it doesn't have different values -- it's either present or it's not, which makes it the so-called boolean attribute.

Anyway, this should do the trick:

{{ Form:: text('title', null, array('class' => 'form-control', 'required' => '')) }}

See more here.

Upvotes: 3

Related Questions