Login Retreive lost passwordRegister
Search

Forum Index / General / Add dynamically new fields

[ This topic is solved ]

  fulvio 04 January 10 / 16:09  
I would like to add dynamically new fields to the form without reload the page.
Does sameone have any ideias???

  fulvio 04 January 10 / 17:36  
Ok i can add dynamically the fields but when i submit it show in a print_r($_POST), but not in the FH3 var_dump, what do i have to do first.

  winus 05 January 10 / 09:03  
That's probably because the field aren't registered in the FormHandler object.

  fulvio 05 January 10 / 11:46  
Changed at 05 January 10 / 11:48
Yes i check that i have to user $_POST to get the values and not the $data from the function.

How can a register the fields in FH3???
So it also can validate the fields???

  fulvio 05 January 10 / 16:11  
Ok i did it an small hack, nad it worked.

After adding the html to the form with Jquery "$("#element").after()".

When we print the form we check if an post is made if yes check which field are added.

                    if(isset($_POST['form_reservar_submit'])){ 
  //check for fields added.
  $linhas = array_slice($_POST, 12, -2);
  $nl = count($linhas)/9;

  //print them.
  for($i=2; $i <= $nl; $i++){                    
    $form->textField("1", $i."_Vols", "", "5");
    $form->selectField("2", $i."_Unidade", $opcoes);
    $form->textField("3", $i."_Design", "", "30");
    $form->textField("4", $i."_PBruto", "", "8");
    $form->textField("5", $i."_Comp", "", "8");
    $form->textField("6", $i."_Larg", "", "8");
    $form->textField("7", $i."_Alt", "", "8");
    $form->textField("8", $i."_M3", "", "8");
    $form->textField("9", $i."_Me", "", "8");
  }
}


Sorry for my english.

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license