Loading ...
Sorry, an error occurred while loading the content.

SubForms and Validation

Expand Messages
  • iav8_eh
    After reading the documentation and related post about subforms, I thought that simply setting
    Message 1 of 2 , Aug 6, 2007
    • 0 Attachment

      After reading the documentation and  related post  about subforms, I thought that simply setting the SubForm property on required feilds and the associated Submit button would accomplish the task.  However, I had to insert this code to get the validation step to correctly skip the optional feilds:

      $subform = ($formType='I')? 'integer' : 'real'; 
      if(($error_message=$f->Validate($verify,$subform))=="") {...
      //where $formType is set based on the name of the submit button used}

      With this code the form behaves as expected: only the required feilds are validated.  Without the code, all feilds are validated regardless of their SubForm property setting.  Every feild in my form is a member of one SubForm or the other and each SubForm has one Submit button.

      Am I missing something?  If we must call the Validate function with the SubForm parameter, is there a better way to determine he SubForm in use besides chaecking which Submit button was used?

      BTW: I just started using this excellent class: thanks very much for making it available!

    • Manuel Lemos
      Hello, ... You can use the WasSubmitted function to determine which submit button was used to submit the form. You just need to map submit buttons to
      Message 2 of 2 , Aug 17, 2007
      • 0 Attachment
        Hello,

        on 08/06/2007 01:00 PM iav8_eh said the following:
        > After reading the documentation and related post
        > <http://tech.groups.yahoo.com/group/forms-dev/message/746> about
        > subforms, I thought that simply setting the SubForm property on required
        > feilds and the associated Submit button would accomplish the task.
        > However, I had to insert this code to get the validation step to
        > correctly skip the optional feilds:
        >
        > $subform = ($formType='I')? 'integer' : 'real';
        > if(($error_message=$f->Validate($verify,$subform))=="") {...
        > //where $formType is set based on the name of the submit button used}
        >
        > With this code the form behaves as expected: only the required feilds
        > are validated. Without the code, all feilds are validated regardless of
        > their SubForm property setting. Every feild in my form is a member of
        > one SubForm or the other and each SubForm has one Submit button.
        >
        > Am I missing something? If we must call the Validate function with the
        > SubForm parameter, is there a better way to determine he SubForm in use
        > besides chaecking which Submit button was used?

        You can use the WasSubmitted function to determine which submit button
        was used to submit the form. You just need to map submit buttons to
        sub-forms.

        --

        Regards,
        Manuel Lemos

        Metastorage - Data object relational mapping layer generator
        http://www.metastorage.net/

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/
      Your message has been successfully submitted and would be delivered to recipients shortly.