PHP Classes

SubForm

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  SubForm  >  (Un) Subscribe thread alerts  
Subject:SubForm
Summary:Dont know how to use subforms
Messages:4
Author:guillaume luszack
Date:2007-09-26 12:20:10
Update:2007-09-27 13:27:05
 

  1. SubForm   Reply   Report abuse  
Picture of guillaume luszack guillaume luszack - 2007-09-26 12:20:10
Hello,

I've been trying to set up a subform inside a main form.
This subform is made of a text input and a button which
updates a particular DIV (with the text of the input).
I really don't see how to work it out and I haven't found
much info on subforms in the documentation.
Any help appreciated :)

G.

  2. Re: SubForm   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-09-27 01:34:52 - In reply to message 1 from guillaume luszack
Subforms are for validating only specific inputs when a submit button with the same SubForm value is used to submit the form.

If the sub-form validates, the form is submitted to the server. If you want to execute some other action when a given submit button is used, you can try setting the ONSUBMITTING variable with whatever Javascript to do what you want to do and in the end use "return false;" prevent the form submission.

  3. Re: SubForm   Reply   Report abuse  
Picture of guillaume luszack guillaume luszack - 2007-09-27 06:17:44 - In reply to message 2 from Manuel Lemos
Ok I'll try the ONSUBMITTING event.

Talking about subforms, when I have this inside
a much bigger form :

$form->AddInput(array(
"TYPE"=>"text",
"NAME"=>"pref_location",
"ID"=>"pref_location",
"SubForm"=>"form_add_location",
"MAXLENGTH"=>100,
"LABEL"=>"Enter a location"
));
$form->AddInput(array(
"TYPE"=>"submit",
"ID"=>"add_pref_location",
"NAME"=>"add_pref_location",
"SubForm"=>"form_add_location",
"VALUE"=>"Add location"
));

The submit button submits the whole form instead of just validating
the pref_location field. Am I missing something ?

By the way, how could I have this button validate the field and then
execute an AJAX function and then update a DIV in the page ?

Thanks.

  4. Re: SubForm   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-09-27 13:27:05 - In reply to message 3 from guillaume luszack
The form is submitted when you hit the submit button because you did not set ONSUBMITTING in such way to return false as I described above.

When you use the form_ajax plug-in you can make the whole form or just a sub-form validate right before the form is submitted via AJAX.