Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
checkbox fieldsets repopulate
  • <?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.
  • 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 ?
  • 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', ...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

  • efx August 2018