This is an excerpt from my partials/textfield.blade.php
snippet:
{{ Form::text('mylabel', 'mytext', ['class' =>'form-control']) }}
I know that it's possible to include this snippet and pass some variables to it:
@INCLUDE('partials/textfield', ['required' => 'required', 'autofocus' => 'autofocus'])
I want to be able to call the snippet with optional parameters for required
, autofocus
and readonly
.
My question now is: How can I pass these variables to the form element?
I tried:
{{ Form::text('label',null,
[
'class' =>'form-control',
'required' => (isset($required) ? $required : 'false'),
'readonly' => (isset($readonly) ? $readonly : 'false'),
'autofocus' => (isset($autofocus) ? $autofocus : 'false')
])
}}
This leads to HTML code like ... readonly="false"...
. The presence of readonly
, however, leads internet browsers to render the fields as readonly.
Replacing 'false'
with ''
doesn't help either. Does anyone know, how to pass these optional parameters to the snippet instead?
Any help is greatly appreciated!