0

Set_checkbox() is not working although all is set? I do non compulsory post validation and only trim it to get the value pushed for call_back... When I post the form and other validations are not met, it should go back to the form. When it does, is the checkbox not selected after post even if was checked before submit. What am I missing?

Form / View:

<input type="checkbox" class="hsnb" value="25.00"  name="u" onclick="Calculate()" <?=set_checkbox('u', '25')?>>

The controller:

$this->load->helper('form');
$this->load->library('form_validation');

if($this->input->post('submit2')) {
 $this->form_validation->set_rules('u', 'u', 'trim');
if ($this->form_validation->run() === false)
{
$this->load->view('form', $data);
}
else
{
$this->load->view('form', $data);
}

}
0

1 Answer 1

1

Well basically the value you submitted is returned back to the form you submitted. using the set_checkbox() function, you will check if the submitted value matches the checkbox element's value in which this function is resided.

Why don't you try:

<?=set_checkbox('u', '25.00')?>

the exact value you set for the box!

Codeigniter Documentation

Sign up to request clarification or add additional context in comments.

1 Comment

Lol! Thanks @Afghan Amazing how once can miss such a small thingy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.