Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
checkbox fieldsets repopulate
efx
August 2018
<?php
here the code :
$post = Model_Menu::find($id);
$form->add('render', __('application.render'), array('type' => 'checkbox', 'value'=> 'true', 'data-toggle'=>'toggle', 'data-on' => '<i class="fa fa-eye"></i> '. __('application.menu_visible'), 'data-off' => '<i class="fa fa-eye-slash"></i> '. __('application.menu_invisible'), 'data-onstyle'=>'success', 'data-offstyle'=>'danger', 'id' => 'render', 'data-width' => '150' ));
$form->populate($post);
$form->repopulate();
The problem is that its doesn't repopulate the choice I saved, it return to default chechbox.
I have no problem with dropdown, input etc... its first time I use checkbox in fuel.
I use
http://www.bootstraptoggle.com
checkbox element.
efx
August 2018
The only way is that I setup :
'value'=> $post->render in
fieldsets but its not very elegant because
I should setup
on default value on new data. Sound repopulate doesn't work with checkbox ?
efx
August 2018
I found the fix, I need to setup fieldset with the right value else not it doesn't repopulate :
$form->add('render', 'menu', array('type' => 'checkbox', 'value'=> true, 'data-toggle'=>'toggle', ...
Docs:
https://fuelphp.com/docs/classes/fieldset/fieldset.html#/method_add
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
efx
August 2018