Bonsoir,
je travaille avec codeigniter
J'ai un formulaire de code ci-dessous:
Et un controller qui traite le formulaire dont voici le code:
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" /> <script type="text/javascript" src="<?php echo base_url();?>js/dtable.js"></script> <script> $(document).ready(function() { $("#datesms").datepicker(); }); </script> </head> <body> <?php echo validation_errors('<div class="error">','</div>'); ?> <p class="titre">Rapport de Surveillance Journalier</p> <p>Veuillez entrer les cas observés du jour</p> <?php $attr = array('id=>sms'); echo form_open('insertsms/journalier',$attr); ?> <fieldset> <legend>Informations Générales</legend> <tr> <span>Institution :<input type="text" name="structure"/></span> <span id="dat">Date :<input type="datetime" name="datesms" id="datesms" value="<?php $datestring = "%Y/%m/%d %h:%i";echo mdate($datestring); ?>"/></span> </tr> </fieldset> <table class="dTable" border="none"> <thead> <tr> <th>Pathologie</th> <th>Tranche d'Age</th> <th>Nombre de cas</th> <th>Actions</th> </tr> </thead> <tfoot> <tr> <th colspan="5"><input type="button" value="Ajouter une ligne" onclick="addLigne(this); return false;" /></th> </tr> </tfoot> <tbody> <tr> <td> <select name="patho[]"> <option>Choisissez une pathologie</option> <?php foreach ($patho as $row) { echo "<option value='$row->idpatho'>" . $row->libpatho . "</option>"; } ?> </select></td> <td class="test"> <select name="tranche[]" id="tranche"> <option selected="selected">Choisissez une tranche Age</option> <?php foreach ($age as $row) { echo "<option value='$row->idtranche'>" . $row->tranche_age . "</option>"; } ?> </select></td> </td> <td><input type="text" name="nbcas[]"/></td> <td><input type="button" value="supprimer" onclick="delLigne(this) ;return false;" /></td> </tr> <tr> </tbody> </tr> </table> <td><input type="submit" value="Enregistrer/Envoyer" name="ok" /></td> <td><input type="reset" value="Annuelr" name="cancel" /></td> <?php echo form_close(); ?> </body> </html>
Mon preblème est qu'il ne récupère que les deux premiers champs les autres ne sont pas récupérés et voici quand j'affiche avec print_r ce que j'obtiens:
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 <?php class insertsms extends CI_Controller { function __construct() { parent::__construct(); } function journalier() { $this->form_validation->set_rules('structure','Structure','trim|required|xss_clean'); $this->form_validation->set_rules('patho[]','Patho','trim|required|xss_clean'); $this->form_validation->set_rules('tranche[]','Tranche','trim|required|xss_clean'); $this->form_validation->set_rules('nbcas[]'); $this->form_validation->set_message('required', 'Veuillez remplir les champs vides'); if($this->form_validation->run()) { //$structure_id=$this->input->post('structure'); $date_sms=$this->input->post('datesms'); $pathoid=$this->input->post('patho'); $trancheid=$this->input->post('tranche'); $nb_cas=$this->input->post('nbcas'); for ($i=1; $i < count($pathoid); $i++) { $data = array( 'structure_id' =>$this->input->post('structure'), 'date_sms' =>$this->input->post('datesms'), 'pathoid' =>$this->input->post('patho'.$i), 'trancheid' =>$this->input->post('tranche'.$i), 'nb_cas' =>$this->input->post('nbcas'.$i) ); // $this->model_liste->create($data); echo "<pre>"; print_r($data); echo "</pre>"; } } else { $this->template->write_view('nav','navigation'); $this->template->write_view('logo','logo'); $this->template->render(); $test['result'] = $this->model_liste->getPathologie(); $test['result'] = $this->model_liste->getTrancheAge(); $this->load->write_view('content','vue_insertsms',$test); } } } ?>
Si quelqu'un a une idée de là où ça bugArray
(
[structure_id] => 221779128978
[date_sms] => 2012/06/17 07:41
[pathoid] =>
[trancheid] =>
[nb_cas] =>
)
Array
(
[structure_id] => 221779128978
[date_sms] => 2012/06/17 07:41
[pathoid] =>
[trancheid] =>
[nb_cas] =>
)
Array
(
[structure_id] => 221779128978
[date_sms] => 2012/06/17 07:41
[pathoid] =>
[trancheid] =>
[nb_cas] =>
)
Merci
Partager