Bonjour à tous,

je viens vers vous car je ne vois plus comment récupérer mes valeurs checkbox.

avec un zend_debug, cela m'affiche:

Debugvalue : array(8) {
["name"] => string(1) "4"
["checkbox_service1"] => string(1) "1"
["start_time"] => string(0) ""
["end_time"] => string(0) ""
["checkbox_service2"] => string(1) "1"
["checkbox_service4"] => string(1) "0"
["checkbox_service42"] => string(1) "0"
["Ajouter"] => string(7) "Ajouter"
}

checkbox_service1 : NULL
checkbox_service2 : NULL
checkbox_service4 : NULL
checkbox_service42 : NULL

Ce que je ne comprends pas c'est que dans un premier temps je récupère bien mes 2 checkbox qui sont cochées.
["checkbox_service1"] => string(1) "1"
["checkbox_service2"] => string(1) "1"
mais le debug dit après :
checkbox_service1 : NULL
checkbox_service2 : NULL
si quelqu'un peut m'aider à voir ce qui se passe s'il vous plaît ?

voici le code:

le formulaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
<br /><br />
<div id="view-content">
	<form action="" method="post" id="Ajoutadministratif">
		<p><?=$this->form->name->render();?></p>
		<table >
		   <?php $i = 0;
			foreach ($this->service as $service) :
			$this->form->start_time->setAttrib('id', 'start_time'.$service['id']);
			$this->form->start_time->setAttrib('name', 'start_time['.$service['id'].']');
			$this->form->end_time->setAttrib('id', 'end_time'.$service['id']);
			$this->form->end_time->setAttrib('name', 'end_time['.$service['id'].']');
			$this->form->checkbox_service->setAttrib('name', 'checkbox_service'.$service['id']);
			$this->form->checkbox_service->setAttrib('onclick', 'afficherTime(this, '.$service['id'].')');
			$i++;
			?> 
		<tr>
		   <td><?php echo $service['name']; ?></td>
		    <td><?=$this->form->checkbox_service->render();?></td>
			<td class="time<?=$service['id']?>" style="display:none;"><?=$this->form->start_time->render();?></td>
			<td class="time<?=$service['id']?>" style="display:none;"><?=$this->form->end_time->render();?></td>
		</tr>
		<?php endforeach; ?>
		<table>
		<?=$this->form->Ajouter->render();?>
	</form>
</div>
<script type="text/javascript">
	function afficherTime(element, id)
	{
		if ($(element).is(":checked")) $('.time'+id).show();
		else  $('.time'+id).hide();
	}
</script>
le controller:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
$this->view->form = $form = new Application_Form_Ajoutadministratif();
		$service = new Application_Model_DbTable_Service();
		$this->view->service = $service->lireTout();
 
		if($post = $this->_request->isPost()){
			$formData = $this->getRequest()->getPost();
			if($form->isValid($formData)){
				// Traitement
				try{
					$idContract = (String)$this->_request->getParam('id');
					Zend_Debug::dump($formData, $label = "Debugvalue : ", $echo = true);
 
					foreach ($service->lireTout() as $service) {
 
						$checkboxservice = $form->getValue('checkbox_service'.$service['id']);
						Zend_Debug::dump($checkboxservice, $label =  "checkbox_service".$service['id']." : ", $echo = true);
						if( $checkboxservice == 1 ) {
						echo 1;exit;
							$device['contract_id'] = $idContract;
							$device['production_state_id'] = 1;
 
							$device['netasq_model_id'] = $form->getValue('name');
							$deviceservice['start_time'] = $form->getValue('start_time['.$service['id'].']');
							$deviceservice['end_time'] = $form->getValue('end_time['.$service['id'].']');
							$Devices = new Application_Model_DbTable_Device();
							$idDevice = $Devices->ajouterDevice($device);
							$Deviceservice = new Application_Model_DbTable_Deviceservice();
							$deviceservice['device_id'] = $idDevice;
							$deviceservice['service_id'] = $service['id'];
							$idDeviceservice = $Deviceservice->ajouterDeviceservice($deviceservice);
 
						}
					}
				}catch (Exception $e)
				{
					throw $e;
				}
				//$this->_helper->redirector->gotoSimple('liste');
			}
			else{
				$form->populate($formData);
			}
		}
Merci d'avance de votre aide.

Cordialement,