Dropdown not getting validated - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Dropdown not getting validated (/showthread.php?tid=50109) Pages:
1
2
|
Dropdown not getting validated - El Forum - 03-14-2012 [eluser]xtremer360[/eluser] I'm trying to figure out what I'm doing wrong here. For some reason the dropdown isn't getting validated correctly because it should be coming up with an error message saying this field is required but its not. It should be just like this page for the dropdown. I'm also trying to get it to display the Select an Option default option when the form opens and have that be the option that if its still selected when the form submits then it throws the error saying the field is required. Also not sure about why there's an inner border around the form. http://www.kansasoutlawwrestling.com/peach/forms.html Code: <?php echo form_label('Recipient', 'recipient'); ?> This is what the rendered page looks like http://jsfiddle.net/tNFNY/ Dropdown not getting validated - El Forum - 03-14-2012 [eluser]InsiteFX[/eluser] Code: <?php Dropdown not getting validated - El Forum - 03-14-2012 [eluser]CroNiX[/eluser] Try set_value('recipient', 0); instead of -1 for the selected value to set the select value to what the last form submission was or 0 (your default value) if no form was submitted. Dropdown not getting validated - El Forum - 03-14-2012 [eluser]xtremer360[/eluser] So I ended up changing it to a muliple select with the following and trying having it validate and nothing I'm still not getting a validation error. Code: <?php echo form_label('Recipient', 'recipient'); ?> Dropdown not getting validated - El Forum - 03-14-2012 [eluser]CroNiX[/eluser] Well, now you removed the default option with the 0 index. Show where you set the validation rules for recipient and where you execute them. Dropdown not getting validated - El Forum - 03-14-2012 [eluser]xtremer360[/eluser] Here's the controller code for when the user submits the form: Code: // Function used for login form validation Dropdown not getting validated - El Forum - 03-14-2012 [eluser]xtremer360[/eluser] Keep in mind that this multiple select can have one selection or more. Dropdown not getting validated - El Forum - 03-14-2012 [eluser]CroNiX[/eluser] In your code you have pmmmodel and also pmmodel. Which is it or do you actually have 2 models named like that? Dropdown not getting validated - El Forum - 03-14-2012 [eluser]xtremer360[/eluser] oops but by that time the field should have already been validated Dropdown not getting validated - El Forum - 03-14-2012 [eluser]CroNiX[/eluser] All of your options have integers as values, so it will always pass your rule because it has a value which will make it pass the Required rule and it is an integer. |