![]() |
combo box - 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: combo box (/showthread.php?tid=65905) |
combo box - davy_yg - 08-08-2016 Hello, Can anyone help me find the right code to input combo box through model? I think I should change role input text into some other codes since it is a combo box that I am trying to input into the database. PHP Code: 'role' => $this->input->post('email') controllers/cpages.php PHP Code: public function addusers() { views/addusers.php PHP Code: <tr> models/Mpages.php PHP Code: public function add_user() RE: combo box - InsiteFX - 08-09-2016 Maybe read the CodeIgniter Users Guide on the Form Helper form_dropdown() RE: combo box - davy_yg - 08-09-2016 (08-09-2016, 05:32 AM)InsiteFX Wrote: Maybe read the CodeIgniter Users Guide on the Form Helper form_dropdown() Yes, I already read the user guide but do not know how to fix the model. models/Mpages.php PHP Code: public function add_user() I should change the role into something else since it is a dropdown box. PHP Code: 'role' => $this->input->post('email') RE: combo box - davy_yg - 08-15-2016 This is my revision but I still get strange result: PHP Code: public function add_user() username email password role user [email protected] 12345678 <select name="roles" RE: combo box - PaulD - 08-16-2016 You have not read the docs! Clearly. http://www.codeigniter.com/user_guide/helpers/form_helper.html#form_dropdown Why would you put the output of form_dropdown function into an array with input posts that you then insert into your database!!!!! I seriously do not know whether to laugh or cry! This will tell you how dropdowns work http://www.html-form-guide.com/php-form/php-form-select.html Now you have a post field with your dropdown option value. Access it just like you would any other input post. The form helper just helps you to write your select HTML a bit more easily than writing it all out. Did you say you were building an eCommerce CMS? OMFG :-( |