CodeIgniter Forums
arrays and set_value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: arrays and set_value (/showthread.php?tid=15668)



arrays and set_value - El Forum - 02-11-2009

[eluser]Ward[/eluser]
Hi

I cant work out what I'm missing here.

set_value(price[]) returns an array and not an integer when repopulating the form. Acording to my reading of the manual it ought to work.

Code:
class Welcome extends Controller {
    
    function index(){
        $this->load->library('form_validation');
        $this->load->helper('url');
        $this->form_validation->set_rules('price[]', 'P', 'required');
            if ($this->form_validation->run() == FALSE){
            $this->load->view('welcome_message');
        }
    }
}




Code:
<form method=POST action="<?current_url()?>" />

<p>&lt;input type="text" name="price[]" value="&lt;?=set_value('price[]')?&gt;"&gt;

<p>&lt;input type="text" name="price[]" value="&lt;?=set_value('price[]')?&gt;"&gt;

<p>&lt;input type="submit"&gt;

&lt;/form&gt;

Thanks


arrays and set_value - El Forum - 03-23-2009

[eluser]Kenzie[/eluser]
I'm seeing the same issue.

Code:
$this->form_validation->set_rules('options[]', 'Options', 'required');
&lt;input type="text" name="options[]" value="&lt;?php echo set_value('options[]'); ?&gt;" size="50" /&gt;

When the form is redisplayed because of an error, the input field simply says 'Array', instead of the actual value.


arrays and set_value - El Forum - 03-23-2009

[eluser]xwero[/eluser]
try it with the numbers
Code:
<p>&lt;input type="text" name="price[0]" value="&lt;?=set_value('price[0]')?&gt;"&gt;

<p>&lt;input type="text" name="price[1]" value="&lt;?=set_value('price[1]')?&gt;"&gt;



arrays and set_value - El Forum - 03-23-2009

[eluser]Kenzie[/eluser]
That didn't work, and actually prevented any input from being redisplayed.


arrays and set_value - El Forum - 03-23-2009

[eluser]cwt137[/eluser]
Hello,

Please try my patch: http://ellislab.com/forums/viewreply/518380/