Welcome Guest, Not a member yet? Register   Sign In
passing array to controller
#1

[eluser]Unknown[/eluser]
Hello everyone,

I am new to CI, and find some problem when passing array from view to controller.
Supposed I have array like this :

Code:
$data['task_no'] = 'JC_001';
$reference = array('Task_1','Task_2','Task_3');
$data['reference'] = $reference;
$this->load->view('myview', $data);

I want to make 'edit' link from view to controller,
therefore I need to pass 'task_no' and array 'reference' within link like so :

Code:
&lt;?php echo "<td>". anchor('perf/editmat/'.$task_no.'/'.serialize($reference),'Edit') ."</td>"; ?&gt;

But somehow, an error appear :
Code:
An Error Was Encountered
The URI you submitted has disallowed characters.

Is it possible to pass array to controller?

Thanks for the help.
#2

[eluser]bientek[/eluser]
Since the URL characters are restricted for security reasons, maybe a better way to pass data to the controller would be through hidden form fields.

Look at "Adding Hidden Input Fields" on this page.
#3

[eluser]mi6crazyheart[/eluser]
Sending an array of data in url!!!. Can't give any solid reason but i don't feel it's a proper way...




Theme © iAndrew 2016 - Forum software by © MyBB