![]() |
how to pass array from view to controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how to pass array from view to controller (/showthread.php?tid=63988) |
how to pass array from view to controller - Midhun Mohanan P - 12-31-2015 how to pass array from view to controller...please help yaa. ![]() RE: how to pass array from view to controller - Martin7483 - 12-31-2015 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. RE: how to pass array from view to controller - includebeer - 12-31-2015 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? RE: how to pass array from view to controller - Midhun Mohanan P - 01-01-2016 (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 ? RE: how to pass array from view to controller - includebeer - 01-01-2016 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-array-values-from-dynamic-input-fields-using-php PHP Code: <form method="post" action="collect_vals.php"> RE: how to pass array from view to controller - olivedev - 09-19-2017 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-pass-data-in-codeigniter/ RE: how to pass array from view to controller - Azhahesan Kumar - 01-31-2019 (12-31-2015, 03:06 AM)Martin7483 Wrote: You don't pass data from a view to a Controller. You pass data from a Controller to a View. Using Ajax I need to pass an array of data to the controller RE: how to pass array from view to controller - raviksharma - 03-28-2019 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* |