set_value() in CI3 has issues with input arrays |
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.
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.
(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/l...ield-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.
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/l...controller personally i would just autoload form helper and url helper in: application/config/autoload then you don't have to worry about it. (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 . ![]()
Check your PHP version and make sure your running PHP 5.6 or newer.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |