CodeIgniter Forums
form validation, set_value and initial value - 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: form validation, set_value and initial value (/showthread.php?tid=71230)



form validation, set_value and initial value - foxbille - 07-21-2018

Hello,
It seems impossible to set initial value to a form field when you need to use set_value() function to repopulate the form field with the submitted data, Am I wrong ?
"Placeholder" might be a solution to suggest something to the end-user but when it comes to "date", setting initial value to date-of-the day is so comfortable ...
Help and / or explanations will be apreciated.
Thanks,
Eric


RE: form validation, set_value and initial value - PaulD - 07-22-2018

You are wrong  Smile

In the docs:
https://www.codeigniter.com/user_guide/helpers/form_helper.html#set_value

You would set a value like this:
PHP Code:
<input type="text" name="quantity" value="<?php echo set_value('quantity', '26'); ?>" size="50" /> 

This would set a default value of 26 to the input field.

I hope that helps,

Paul

PS The docs are excellent - they are worth reading in detail.


RE: form validation, set_value and initial value - foxbille - 07-22-2018

Sure it helps ! Heedless was I, thanks !