I have a text box that needs to be made readonly
; I don't want to use array('disabled' => 'true')
because I need PHP to process the field:
{{ Form::text('login_token', Worker::generateLoginToken()) }}
How do you add this attribute?
I have a text box that needs to be made readonly
; I don't want to use array('disabled' => 'true')
because I need PHP to process the field:
{{ Form::text('login_token', Worker::generateLoginToken()) }}
How do you add this attribute?
Just add it as the 3rd argument:
{{ Form::text('login_token', Worker::generateLoginToken(), ['readonly']) }}
That's how I did it in Laravel 5:
{!! Form::text('id', null, ['class' => 'form-control', 'readonly' => 'true']) !!}
Cheers.
For Laravel 5 and above
{!! Form::text('name', 'default-value', ['class'=>'class-name','readonly']) !!}
In third argument you can pass all your extra arguments in form of an array. This line will result into something like this in html.
<input class="class-name" readonly="readonly" name="name" type="text" value="default-value">
For Laravel < 5 , this should work
{{ Form::text('name', 'default-value', ['class'=>'class-name','readonly']) }}
Write the following line
{!! Form::text('field_name','field_value',array('class'=>'form-control','readonly')) !!}
Try this...
{{ Form::text('login_token', Worker::generateLoginToken(),array('readonly')) }}
I am using Laravel 5.4 along with BootForm, and the only way that it has worked was by doing:
{!! BootForm::text('Name', 'name', $name)->disable() !!}
Based on the docs of adamwathan/form. Hope it helps!
U can try...
'attr' => ['readonly']
Example:
$this->add('created_at', 'text', [
'label' => 'Data do contato',
'value' => $this->model->created_at->format('d/m/Y H:i:s'),
'attr' => ['readonly']
]);
© 2022 - 2024 — McMap. All rights reserved.