set_value() in CI3 has issues with input arrays - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: set_value() in CI3 has issues with input arrays (/showthread.php?tid=66360) |
set_value() in CI3 has issues with input arrays - zknight - 10-14-2016 In Codeigniter 2 our forms were able to have PHP Code: <input type="text" name="options[]" value="<?php echo set_value('options[]'); ?>" size="50" /> The error PHP Code: A PHP Error was encountered I did look at the form_helper from CI2 and I saw it parsed out the values if it saw an array and returned them differently than they are being done in CI3. RE: set_value() in CI3 has issues with input arrays - cartalot - 10-14-2016 hi - hey i can confirm this does work for me in CI 3 so there must be something else going on. Are you using CI form validation? Are you sure you have 'field' => 'options[]' in the form validation? Are you sure you are loading form helper? If none of those things solve it then try naming the field something different then 'options' - maybe you have a conflict. And if that does not work then post more of your code and the specific error messages you are getting. RE: set_value() in CI3 has issues with input arrays - zknight - 10-14-2016 (10-14-2016, 02:04 PM)cartalot Wrote: hi - hey i can confirm this does work for me in CI 3 so there must be something else going on. Are you using CI form validation? Are you sure you have 'field' => 'options[]' in the form validation? Are you sure you are loading form helper? If none of those things solve it then try naming the field something different then 'options' - maybe you have a conflict. And if that does not work then post more of your code and the specific error messages you are getting. Not sure what you mean by 'field' => 'options[]'? I use PHP Code: $this->form_validation->set_rules('options[]', 'Options', 'required'); I'm referencing https://www.codeigniter.com/userguide3/libraries/form_validation.html#using-arrays-as-field-names for this post by the way. Also, there is no other error messages, it's just that set_value() returns the whole array instead of the individual fields. Also, I'm using form_validation obviously and form_helper is loaded automatically(unless this changed in CI3) when you load that library. RE: set_value() in CI3 has issues with input arrays - cartalot - 10-16-2016 i think you do need to load the form helper - or at least it shows doing that in the form validation example in the manual. https://www.codeigniter.com/userguide3/libraries/form_validation.html#the-controller personally i would just autoload form helper and url helper in: application/config/autoload then you don't have to worry about it. RE: set_value() in CI3 has issues with input arrays - ronykader - 11-01-2016 (10-16-2016, 10:50 AM)cartalot Wrote: i think you do need to load the form helper - or at least it shows doing that in the form validation example in the manual. Already I have done everything in previous as your instruction but till now not working. And Getting error till now . RE: set_value() in CI3 has issues with input arrays - InsiteFX - 11-02-2016 Check your PHP version and make sure your running PHP 5.6 or newer. |