0

I want add 11 rows in the table.

in view :

<?php echo $this->form->create('Detail',array('action'=>'add'));?> <fieldset>
  <legend>Add New Detail</legend><?php for($i=0;$i<$count;$i++){
  echo $this->form->input('Detail.$i.name');
  echo $this->form->input('Detail.$i.text');
  echo $this->form->input('Detail.$i.taille');
  echo $this->form->input('Detail.$i.police');
  echo $this->form->input('Detail.$i.bold');
  echo $this->form->input('Detail.$i.italic');

  echo $this->form->input('ticket_id');}?>

form->end('Submit');?>

in my controller DetailsController:

 public function add($count=1) {

  $tickets= $this->Detail->Ticket->find('list');
  pr($tickets);
  if($this->request->is('post')){
 $this->Detail->saveAll($this->request->data['Detail']);}     
     $this->set('tickets', $tickets);$this->set('count', $count);}

my problem is : the code save 11 rows similar to the last input( exp: in browser i add nom1 nom2 nom3 .. nom11 but in table: add 11 rows renamed nom11 ) I'am sorry my bad English language

1 Answer 1

1

May be there is some issue with your fields name. Try this may be this will work :-

<?php
  echo $this->form->create('Detail',array('action'=>'add'));
?> 
 <fieldset>
  <legend>Add New Detail</legend>
 <?php 
    for($i=0;$i<$count;$i++){
       echo $this->form->input("Detail.$i.name");
       echo $this->form->input("Detail.$i.text");
       echo $this->form->input("Detail.$i.taille");
       echo $this->form->input("Detail.$i.police");
       echo $this->form->input("Detail.$i.bold");
       echo $this->form->input('Detail.$i.italic');
       echo $this->form->input("ticket_id");
    }
  ?>    
Sign up to request clarification or add additional context in comments.

7 Comments

but 'ticket_id' foreing key it display 11 time.
i want ticket_id display for the all form
please change echo $this->form->input("ticket_id"); to echo $this->form->hidden("ticket_id"); and check
it's save 'ticket_id' at value 0
but I want to save at value 1
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.