dropdown with multiple |
Hello, I wanted to use dropdown with multiple attribute using helper forms:
PHP Code: <?= form_dropdown('dpd', array( PHP Code: $drpdown = $this->request->getPost('dpd'); I choose several values, expect to get something like an array... but instead I get: Code: string '3' (length=1) Yes, this value also participates in the sample, but it is chosen last. There should be 2 more. What have I done wrong? Thanks! (07-22-2018, 01:46 AM)Pertti Wrote: The name of the dropdown has to be array as well: Forgive me, I forgot about this, similar situation was with multi-uploading files. Thank you!
You could also use this.
PHP Code: <?= form_multiselect('dpd[]', ['1' => 'First', '2' => 'Second', '3' => 'third', '4' => 'fourth',], '2', "class = 'form-control'"); ?> (07-26-2018, 03:09 PM)Друг друга. Wrote: You could also use this. Thank you, but what is the difference between an example taken from the documentation where the classical array record is used and the reduced record of the array from yours?
(07-27-2018, 04:05 AM)Nome Wrote: Thank you, but what is the difference between an example taken from the documentation where the classical array record is used and the reduced record of the array from yours? The array syntax makes no difference and isn't the point. The point is the use of form_multiselect instead fo form_dropdown. Creating an array using the array() language construct, e.g. PHP Code: array('1' => 'First', '2' => 'Second', '3' => 'third', '4' => 'fourth',) PHP Code: ['1' => 'First', '2' => 'Second', '3' => 'third', '4' => 'fourth',] I'm just in the habit of using the short syntax because I like typing less to get the same results. Sorry if that caused confusion. |
Welcome Guest, Not a member yet? Register Sign In |