Re-populate checkbox if it fails in validation in an edit form in Codeigniter

前端 未结 5 396
谎友^
谎友^ 2021-01-16 18:13

I works on the an data-edit form in codeigintier. And the problem is about re-populate checkbox

It works if it is an add form (that means I need not concern about th

5条回答
  •  抹茶落季
    2021-01-16 19:00

    You can use form_checkbox() function: Guide

    $isChecked = False; // or True for default value
    

    If have stored data then:

    $isChecked = $customer_group[0]['is_default']; echo form_checkbox('input_name', 'value', $isChecked);

    or the hard way: set_checkbox():

    The first parameter must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE)

    />

提交回复
热议问题