Значение флажка не сохраняется в PHP (Codeigniter) - PullRequest
1 голос
/ 14 ноября 2011

После проверки формы я собираю следующую информацию.

$inscription_parent['tempassword'] = $this->input->post('password');
$inscription_parent['matchingPassword'] = $this->input->post('matchingPassword');
$inscription_parent['nameUser'] = $this->input->post('nameUser');
$inscription_parent['firstNameUser'] = $this->input->post('firstNameUser');
$inscription_parent['sexUser'] = $this->input->post('sexUser');
$inscription_parent['emailUser'] = $this->input->post('emailUser');
$inscription_parent['phoneHomeUser'] = $this->input->post('phoneHomeUser');
$inscription_parent['phoneCellUser'] = $this->input->post('phoneCellUser');
$inscription_parent['phoneWorkUser'] = $this->input->post('phoneWorkUser');
$inscription_parent['workUser'] = $this->input->post('workUser');
$inscription_parent['chkAnimation'] = $this->input->post('chkAnimation');
$inscription_parent['chkGestion'] = $this->input->post('chkGestion');
$inscription_parent['chkAccompagnement'] = $this->input->post('chkAccompagnement');
$inscription_parent['chkCouture'] = $this->input->post('chkCouture');
$inscription_parent['chkCuisine'] = $this->input->post('chkCuisine');
$inscription_parent['chkAutre'] = $this->input->post('chkAutre');
$inscription_parent['autreImplication'] = $this->input->post('autreImplication');

$this->session->set_userdata($inscription_parent);

Как вы могли заметить, переменные с именем chk являются переменными. Их значения по умолчанию следующие: -

<input id="chkAnimation" name="chkAnimation" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="chkAnimation">Animation</label>
<input id="chkGestion" name="chkGestion" class="element checkbox" type="checkbox" value="2" />
<label class="choice" for="chkGestion">Gestion/Comptabilité</label>
<input id="chkAccompagnement" name="chkAccompagnement" class="element checkbox" type="checkbox" value="3" />
<label class="choice" for="chkAccompagnement">Accompagnement (sorties)</label>
<input id="chkCouture" name="chkCouture" class="element checkbox" type="checkbox" value="4" />
<label class="choice" for="chkCouture">Couture, costumes</label>
<input id="chkCuisine" name="chkCuisine" class="element checkbox" type="checkbox" value="5"/>
<label class="choice" for="chkCuisine">Cuisine (cuistot)</label>
<input id="chkAutre" name="chkAutre" class="element checkbox" type="checkbox" value="6"/>
<label class="choice" for="chkAutre">Autre</label>

Когда я печатаю содержимое массива после операции отправки, все сохраняется правильно, но не флажки! Неважно, какой я проверяю или снимаю галку, все это будет иметь:

(chk(variable)=> )

Можешь помочь?

Кстати, они находятся внутри тегов формы.

1 Ответ

1 голос
/ 23 ноября 2011

Проблема заключалась в коде вокруг заполнения массива, что привело к его перезаписи. В любом случае, спасибо за советы.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...