![]() |
I want to return the value entered by the user at the time of validation error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: I want to return the value entered by the user at the time of validation error (/showthread.php?tid=81685) |
I want to return the value entered by the user at the time of validation error - yoshi - 04-09-2022 ## overview where is 'set_fields'. ## reference https://codeigniter4.github.io/userguide/libraries/validation.html ## detail The Codeigniter 3 Tutorial had a special variable called 'set_fields'. The effect was to display the 'post' data entered by the user. Now, when I have a simple "create lesson" controller like this, is there a way to keep the values entered by the user? or should I assign it to '$ _POST' and use 'post' in the template? PHP Code: /** RE: I want to return the value entered by the user at the time of validation error - ignitedcms - 04-09-2022 Do you mean set_value in CI3? If you validate via ajax you wouldn't have to repopulate the form. RE: I want to return the value entered by the user at the time of validation error - yoshi - 04-09-2022 (04-09-2022, 10:44 AM)ignitedcms Wrote: Do you mean set_value in CI3? If you validate via ajax you wouldn't have to repopulate the form. thankyou for reply ignitedcms. the following address is for reference. However, looking inside the `set_value`, it seems that using `$ _POST` after all. ![]() http://www.codeigniter.com/userguide3/helpers/form_helper.html#set_value The tutorial doesn't seem to use `ajax`, but I'd like to take a look at the `ajax` page and create a validation mechanism. https://codeigniter.com/user_guide/libraries/validation.html?highlight=validation#the-form https://codeigniter.com/user_guide/general/ajax.html?highlight=ajax RE: I want to return the value entered by the user at the time of validation error - kenjis - 04-09-2022 See https://codeigniter.com/user_guide/helpers/form_helper.html#set_value RE: I want to return the value entered by the user at the time of validation error - yoshi - 04-09-2022 thanks kenjis Oh? It seems that I misunderstood that 'set_value' was gone. Thank you RE: I want to return the value entered by the user at the time of validation error - ignitedcms - 04-09-2022 I believe you were looking for 'set_fields' which is IIRC what it was historically named. Additionally in the old documentation there was a section under libraries > validation which discusses repopulating the form which appears to have been omitted, although as Kenjis has kindly pointed out is in the form helper section. Off topic, I do prefer validating forms with ajax calling server side validation as it skips a step of having to manually repopulate input fields, though this is predicated on js being enabled in browser. RE: I want to return the value entered by the user at the time of validation error - yoshi - 04-09-2022 thanks, ignitedcms. Yes. It was exactly the old `set_values` on the Validation page of the old document. I would like to challenge later even if I use Ajax |