3

i have an optional checkbox called checkall

<input name="checkall" type="checkbox" value="ON" <?php echo set_checkbox('checkall', 'ON'); ?> />

i'm sure that the form is submitting that

if i give it a validation rule $this->form_validation->set_rules('checkall', 'Checkall', 'required');it works, but without a rule nothing worked out !

did i miss something? i think form helper doesn't require that for this function to work right ?

1
  • ME.to.YOU Please add some detail on the error you are encountering. For example is the Form not submitting? Is the only that checkbox not working? is the Form Validation method not working? Please clarify :) Commented Jun 21, 2011 at 6:36

2 Answers 2

4

I think you're talking about the value being persisted without validation rules. This is STILL a problem in CI 2.x if I recall correctly, and jbreitwiser's patch from January 2010 is still necessary:

http://codeigniter.com/forums/viewthread/96617/P15/#689642

If this is still a problem in CI 2.x it is completely absurd, and I totally agree. But that patch will solve your problem.

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

Comments

0

If I understand you correctly your checkbox is not submitting with the form? If that is the case, I had a fun time with this question on this thread HERE

PHP wants you to check to see if a checkbox is set or not by verifying whether or not there is a corresponding element in the POST array. If the checkbox was checked, there will be an element of the same name in the POST array (that element will have a NULL value), if the checkbox was NOT checked, then there will be NO matching element in the POST array.

The code would look something like this:

Your input element remains the same --

<input name="checkall" type="checkbox" value="ON" <?php echo set_checkbox('checkall', 'ON'); ?> />

Postback Handler Page gets a new way to validate a checkbox --

if(isset($_POST["checkall"])
{
   $checkall = TRUE;
}
else
{
   $checkall = FALSE;
}

Hopefully I helped, its late and your question is sparse on details.

Regards

Comments

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.