how to pass array from view to controller |
how to pass array from view to controller...please help yaa.
Practice | Practice | Practice
You don't pass data from a view to a Controller. You pass data from a Controller to a View.
You do pass input data from a form to a controller.
Do you mean: how to submit a form containing an array, or how to make an ajax request and posting an array, or something else...?
...and then the result will be read by a controller?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
(12-31-2015, 07:10 AM)includebeer Wrote: Do you mean: how to submit a form containing an array, or how to make an ajax request and posting an array, or something else...? ya i mean that. how to pass array on form submition ?
Practice | Practice | Practice
You need to use multiple input with the same name and [] to tell PHP it's an array. The values will be in $_POST["mytext"].
You can find a simple tutorial here : http://www.sanwebe.com/2013/04/capture-a...-using-php PHP Code: <form method="post" action="collect_vals.php">
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
To pass data to view in codeigniter, especially for array, you can do this
PHP Code: $data = array( For multi dimensional array you will have to create loops. Source: https://www.cloudways.com/blog/how-to-pa...deigniter/
Although typically setting the traditional property helps with any time you are passing arrays via AJAX calls, you can still run into issues with serialization. You often need to explicitly set the name of the parameter that you are expecting to populate as seen below :
data: { 'ids': ids }, *SEO link redacted* |
Welcome Guest, Not a member yet? Register Sign In |