i have a problem where a checked checkbox is not displaying checked.
My view:
#if(in_array($searchgroup->id.','.$searchtag->id, session()->get('zoektermen')))
{{ Form::checkbox($searchtag->naam,$searchgroup->id. ',' .$searchtag->id, true, ['class' => 'search-checkbox']) }} {{ $searchtag->naam }}
#else
{{ Form::checkbox($searchtag->naam,$searchgroup->id. ',' .$searchtag->id, null,['class' => 'search-checkbox']) }} {{ $searchtag->naam }}
#endif
I'm using laravel collective.
I'm using this code on other places on the website in different scenario's, where this works perfectly and the checkboxes display checked.
I'm using firefox but i also tried safari, no difference.
Any help is appreciated..
Consider the example having checked checkbox or not depending on the say user status Active or Inactive
{!! Form::checkbox('status', 'Active', ($userData->status == 'Active') ? 'checked="checked"' : '' ,['data-prompt-position' => 'centerRight','data-title'=>'Active']) !!}
If you have included "uniform.default.js" in your project, it can create such an issue. Please use the following code to resolve it.
$('#checkbox').prop('checked',true).uniform('refresh');
Further reading: jQuery Uniform Checkbox does not (un)check
Thanks.
Related
I have this dropdown i want to make it read only or disable
{{ Form::select('name[]',$names,$name : '' ,['class'=>'form-control name input_fields','readonly'=>true,'id'=>'name']) }}
tried disabled also
{{ Form::select('name[]',$names,$name : '' ,['class'=>'form-control name input_fields','disabled'=>true,'id'=>'name']) }}
but i want to disable options only the option that is pre-selected should be saved in database, using readonly i can change the dropdown and using disable i can't get its value.
This worked for me
# assume "$names" as your data array, which comes from the backend
#php
$names = array('L' => 'Large', 'S' => 'Small')
#endphp
{{ Form::select('name[]',$names, '' ,['class'=>'form-control name input_fields','disabled'=>true,'id'=>'name']) }}
In form remove "$names,$name : ''" and run only with $names array
You have to use a hidden input
Example based on your code ..
{{ Form::select('name_placeholder', $names, $name , ['class'=>'form-control name input_fields', 'readonly'=>true,' id'=>'name']) }}
{{ Form::hidden('name', $name) }}
I simply want to give the text element of my edit-form a class.
{{ Form::text('first_name') }}
I know that i have to use an array with the class of the field as third argument. But i do NOT want to give a second argument. This one
{{ Form::text('first_name' , ' ' , array('class' => 'form-control')) }}
applys the class correctly, but sets the dafault value to an empty string. This is a problem, because now laravels auto-complete function doesn't fill the form with the correct data from the database. Is there a way to give no second argument or setting it to default like this?
{{ Form::text('first_name' , default , array('class' => 'form-control')) }}
Thanks!
Okay, i solved it myself. It is as easy as it always is. Simply use
{{ Form::text('first_name' , null , array('class' => 'form-control')) }}
I have been reading about form model binding https://laravelcollective.com/docs/5.0/html#form-model-binding
It's very cool to populate DB values in html form.
I tried like this and this works fantastic.
{{ Form::model($university,array('url' => admin_path('universities/edit'),'id' => 'add_university','name' =>'add_university','data-validate'=>"parsley")) }}
{{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
{{ Form::text('university_name')}}
{{Form::close()}}
But the problem is here, Cause i want to add more attributes in input like class SO i am using
{{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
{{ Form::text('university_name','',array('class' => 'form-control'))}}
If i leave blank valuecolumn then nothing populate in textbox and if i using like this
{{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
{{ Form::text('university_name',$university->university_name,array('class' => 'form-control'))}}
Then what is use of model binding.
Please explain.
Thanks
{{ Form::text('university_name','',array('class' => 'form-control'))}}
It should be:
{{ Form::text('university_name',null,array('class' => 'form-control'))}}
'' means the real string, not null.
thanks, mathielo, for helping me on grammar
I'm implementing bootstrap-slider in my CRUD, I have implemented it successfully in Create, the problem is when I try to edit it,
I want to get the current value from the Model. Idk how to do this.
This is for PATCH.
<div class="form-group">
<h3 class='box-title text-info'>Percentage</h3>
{!! Form::input('text','percentage',null,['id'=>'ex8', 'data-slider-id'=>'ex1Slider', 'data-slider-min'=>'0', 'data-slider-max'=>'100', 'data-slider-step'=>'5', 'data-slider-value'=>'50']) !!}
</div>
In your form instead of creating a new form. You will bind the form to the model.
{!! Form::model('modelname', [options here] !!}
All the fields will math the model's property values.
Edit
Here is an example
You must used something like this to create a EDIT FORM
{{ Form::model($smartphones, ['method' => 'PATCH', 'url' => 'smartphones/'.$smartphones->id]) }}
You get by using $(your_model)['inputID']...You can use in "data-slider-value"... Something like this
{{ Form::input('text','mem_ram', null, ['id' => 'mem_ram', 'data-slider-value'=>$smartphones['mem_ram']]) }}
I need to input text name and id dynamically and I am trying as below
{{ Form::text('practice', $practice->name, array('class' => 'large-2','id'=<?php echo $inputTextName;?>)) }}
But it is not parsing PHP here. Even I tried 'id'={{$inputTextName}} but it is giving error.
Can you try this,
{{ Form::text('practice', $practice->name, array('class' => 'large-2','id'=>$inputTextName)) }}