Welcome Guest, Not a member yet? Register   Sign In
arrays and set_value
#1

[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
#2

[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.
#3

[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;
#4

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

[eluser]cwt137[/eluser]
Hello,

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




Theme © iAndrew 2016 - Forum software by © MyBB