I'm trying to get the values of a select element that has the multiple attribute using jInput. I estimate to obtain a series of values but only obtain the value of the last selected option
The definition of the select is as follows
... other inputs ...
<select name="jform[something]" id="something" multiple>
<option value="A">A</option>
<option value="B">B</option>
<option value="...">...</option>
<option value="Z">Z</option>
</select>
In the controller I have the following logic that obtains the values of the inputs including the select.
$requestData = $this->input->post->get('jform', array(), 'array');
Here I hope that the value of the select is a series of selected values but as I mentioned before I get only the value of the last selected option.
The content of $requestData
looks like this
$requestData = [
'name' => 'name',
'lastname' => 'lastname',
...
'something' => 'A' // Here I am expeting to have something like 'A,Z'
];
How do I get the desired values?
The controller code belongs to the controller .../components/com_users/ controllers/registration.php
in the register
method
If you want to get multiple values from select box make that field as array.
Your field name will be - jform[something][]
<select name="jform[something][]" id="something" multiple>
...
</select>