Hi All,
I am building a car dealer app for a friend using Ci 3 and HMVC.
from the database i am querying a set of car options, that get listed in a view file as checkboxes.
in the controller :
PHP Code:
function list_options(){
$mysql_query = "SELECT t1.option_name
, t2.id
, t2.parent_name
FROM option_children AS t1
LEFT OUTER JOIN option_parents AS t2
ON t2.id = t1.parent_id";
$query = $this->_custom_query($mysql_query);
$result = $query->result();
var_dump($result); die();
foreach($result as $row){
$groupedData[$row->parent_name][] = $row->option_name;
}
return $groupedData;
}
and displayed in a form like this :
PHP Code:
foreach ($caroptions as $key => $value) {
echo '<dl style="margin-bottom: 1em;">';
echo "<dt>$key</dt>";
foreach ($value as $row ) {
?>
<div class="checkbox">
<label>
<input name="options[<?= $row ?>]" value ="1" type="checkbox">
<?= $row ?>
</label>
</div>
<?php }
?>
</dl>
<?php
}
so far so good, but when i actually select some of the checkboxes and submit the form , data gets collected like this :
PHP Code:
$data["optionsarray"] = $this->input->post('options[]', TRUE);
Now, when the key contains spaces, this does not work and an empty key is returned. like ["0"] => string(1)"1" for example if i select an option called:
2 door , then the key will not be [2 door] but it will be empty. Same goes for when i use 2 words seperated by a space like " heated seats"
if i use words that have no spaces like "ABS" or "airconditioning" then the key is set and will return
["ABS"]=> string(1) "1"
When i recreate the above scenaria in plain PHP, it works without errors.
i have no idea why this is not working in codeigniter? anyone any idea?