Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Validating Select Menu with CI4 Form Helper
#1

(This post was last modified: 05-26-2021, 09:53 AM by BlackBones.)

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.
Reply
#2

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#3

(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
Reply
#4

Please add [SOLVED] to your topic Title for other users.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB