CodeIgniter Forums
[SOLVED] Validating Select Menu with CI4 Form Helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: [SOLVED] Validating Select Menu with CI4 Form Helper (/showthread.php?tid=79290)



[SOLVED] Validating Select Menu with CI4 Form Helper - BlackBones - 05-24-2021

I just moved one of my projects from CI3 to CI4, and I'm using CI (auto) Model. I think validating HTML select menus works differently in CI4, as I have done everything to get my select menu fields to be validated.

Text input fields are validated without any issues, BUT select menu validation always fails even when an option is selected and form submitted. The select field is set as a "sticky field" (using "set_select()") which works correctly on page redirect to same page.

Any help anyone please?
Thanks.


RE: Validating Select Menu with CI4 Form Helper - includebeer - 05-24-2021

There's no difference in validating a text input filed or a select field. When you get the values in your controller, it's just values in the $_POST array. CodeIgniter don't even know if it comes from an input text or a select field. Maybe post your form and your controller. There must be some bug in your code.


RE: Validating Select Menu with CI4 Form Helper - BlackBones - 05-25-2021

(05-24-2021, 01:35 PM)includebeer Wrote: There's no difference in validating a text input filed or a select field. When you get the values in your controller, it's just values in the $_POST array. CodeIgniter don't even know if it comes from an input text or a select field. Maybe post your form and your controller. There must be some bug in your code.

Thank you @includebeer Shy .

Problem has been been solved! Cool

There were validation errors because I previously matched CI Model $allowedFields array variable with my form input field names. Matching CI Model $allowedFields array variable with database table fields solved the problem!

Sometimes, one just only needs an extra pair of eyes! Idea

Heart


RE: Validating Select Menu with CI4 Form Helper - InsiteFX - 05-26-2021

Please add [SOLVED] to your topic Title for other users.


RE: Validating Select Menu with CI4 Form Helper - BlackBones - 05-26-2021

(05-26-2021, 09:15 AM)InsiteFX Wrote: Please add [SOLVED] to your topic Title for other users.

Thanks @InsiteFXCool
Just getting a hang of forum rules. Shy