Bonjour à tous,

je souhaite faire un update multiple pour les champs où la chekbox est sélectionnée mais ça ne marche pas...
Je suis sous codeigniter, voici les lignes de code concernées :

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
 
function update_matchs() {
	if($this->input->post('Update_matchs')=='oui') {
		$data = array();
		$match_id    = $this->input->post('match_id');
		$match_goal1 = $this->input->post('match_goal1');
		$match_goal2 = $this->input->post('match_goal2');
		$forfait     = $this->input->post('forfait');
 
		foreach( $match_id as $rec_key => $rec_val) {
			if($match_goal1[$rec_key] == '' ) { $match_goal1[$rec_key] = '-1'; } 
			if($match_goal2[$rec_key] == '' ) { $match_goal2[$rec_key] = '-1'; } 
			$data[] = array(
					'match_goal1' => $match_goal1[$rec_key],
					'match_goal2' => $match_goal2[$rec_key],
					'forfait' 	  => $forfait[$rec_key],
					'match_id'    => $match_id[$rec_key],
			);
		}
 
		echo '<pre>';
		print_r($data);
		echo '</pre>';
		exit;
 
		$this->db->update_batch('foot_matches', $data, 'match_id'); 
		redirect('admin/Update_matchs/ModifOK');
	}
}
j'ai volontairement décommenté le print_r($data) pour voir ce qu'il se passe et tout fonctionne sauf la valeur de la checkbox.
Voici le retour du print_r :
Array
(
    [0] => Array
        (
            [match_goal1] => 3
            [match_goal2] => 6
            [forfait] => 
            [match_id] => 2587
        )

    [1] => Array
        (
            [match_goal1] => 8
            [match_goal2] => 2
            [forfait] => 
            [match_id] => 2503
        )

    [2] => Array
        (
            [match_goal1] => 0
            [match_goal2] => 5
            [forfait] => 
            [match_id] => 2506
        )

    [3] => Array
        (
            [match_goal1] => -1
            [match_goal2] => -1
            [forfait] => 
            [match_id] => 2504
        )
... etc (la valeur des goals à -1 signifiant que le match n'est pas encore joué)

Dans le formulaire, avant de l'envoyer, j'avais sélectionné la checkbox du match_id 2506 signifiant que c'est 5-0 forfait et non le résultat du match.
Comme vous voyez, il n'y a jamais de valeur à 'forfait' (que la checkbox soit sélectionnée ou non ...

Merci de votre aide.