I want set read only field dynamically :
In Controller:
$is_read =true;
In Blade form:
{!!Form::text('name',$company_name,array('id'=>'rc_name','class'=>'form-control','placeholder'=>'Name','readonly'=>'$is_read'))!!}
Please help.
I want set read only field dynamically :
In Controller:
$is_read =true;
In Blade form:
{!!Form::text('name',$company_name,array('id'=>'rc_name','class'=>'form-control','placeholder'=>'Name','readonly'=>'$is_read'))!!}
Please help.
Try This:
{!!Form::text('name',$company_name,array('id'=>'rc_name','class'=>'form-control','placeholder'=>'Name', $is_read ? 'readonly' : ''))!!}
The readonly attribute is a boolean attribute.
When present, it specifies that an input field is read-only.
A read-only input field cannot be modified (however, a user can tab to it, highlight it, and copy the text from it).
The readOnly property sets or returns whether a text field is read-only, or not. So readOnly="true" or readOnly="false" is not effected its working.
I've fixed it with following:
{!!Form::text('name',$company_name,array('id'=>'rc_name','class'=>'form-control','placeholder'=>'Name',$is_read ? 'readonly':''))!!}
You can add this to your input field in the blade
{{$is_read ? 'readonly':''}}
it could be something like below
<input type="text" class="input form-control" id="rc_name" name="rc_name" value="{{$company_name}}" {{$is_read ? 'readonly':''}} >