Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      Class: __FormComponent


      Class Overview

      A form component represents a form to submit information filled by the user to the server.


      Form tag is form

      i.e.

      1.    <comp:form name="search_invoices">
      2.  
      3.      Client id: <comp:inputbox name="client_id"/>
      4.  
      5.      <comp:commandbutton type "submit"
      6.                          name "search_button"
      7.                       caption "Search invoices"/>
      8.  
      9.    </comp:form>

      Once a form is submitted, the submit event is raised after validating the submitted information.
      For that purpose, we can add validators to our input components, which are raised before handling the submit event. See the __ValidationRuleComponent for more information about validating components

      A form component redirect the user navigation to the same page by default, however we can define one of the both:

      • A target url and/or a list of parameters, to be loaded after handling the submit or
      • route and/or controller and/or action and/or a list of parameters, to build an url based on those values by ussing the lion url routing engine.

      i.e.
      1.    <comp:form name "search_invoices"
      2.              route "search_invoice"
      3.         parameters "search_mode=1" >
      4.  
      5.      ...
      6.  
      7.    </comp:form>

      In this example, we're going to redirect the navigation flow to the url built by the route "search_invoice". See the URLs and Routes to learn about url routing engine.

      In the other hand, note that we can user parameters in both ways. Parameters is a comma-separated list of name/value pairs, which will be sent to the server as part of the submit.
      In case we are using a route, parameters will be embed within the url if the route defines placeholders for them.


      The submit life-cycle is the following one:

      1. Validate components on client side (if applicable)
      2. Validate components on server side, as a redundant validation (if applicable)
      3. Handle the submit event by calling the correspond event handler method (if applicable)
      4. Redirect the execution to the front controller (continuing the normal execution)

      Form components allow to specify a submit method, by setting the method attribute. Form components also allow a set of parameters to be set as hidden (for HTML clients), by setting the hiddenParameters attribute.


      Author:  Antonio Parraga Navarro
      Version:  1.4
      Copyright:  Copyright (c) 2010 Antonio Parraga Navarro
      __UIComponent
         |
         --__UIContainer
            |
            --__FormComponent

      Methods

      [ Top ]

      Inherited Properties, Constants, and Methods

      Inherited Properties Inherited Methods Inherited Constants

      Inherited From __UIContainer

      Inherited From __UIComponent

      Inherited From __UIContainer

      Inherited From __UIComponent


      [ Top ]

      Method Summary

      string   getAction()   Get the action id to be used by the url routing engine to build the target url
      string   getController()   Get the controller id to be used by the url routing engine to build the target url
      array   getHiddenParameters()   Get the array of parameters to be rendered as hidden parameters within the form
      __Request   getLastRequest()   Gets the last request in which this component was rendered in.
      string   getMethod()   Get the submit method to be used by the current form component
      mixed   getParameters()   Get the parameters to be send within the form submit.
      string   getRoute()   Get the route id to be used by the url routing engine to build the target url
      string   getUrl()   Get the target url to redirect the navigation once the form has been submitted
      void   setAction()   Set the action to be used by the url routing engine to build the target url
      void   setController()   Set the controller to be used by the url routing engine to build the target url
      void   setHiddenParameters()   Set an array of parameters to be rendered as hidden parameters within the form
      void   setLastRequest()   For internal usage only.
      void   setMethod()   Set the submit method, allowing same methods as the HTML form element.
      void   setParameters()   Set a list of parameters (either an array or a comma-separated list) to be sent within the form submit.
      void   setRoute()   Set the route to be used by the url routing engine to build the target url
      void   setTarget()   Alias of __FormComponent::setUrl() method
      void   setUrl()   Set the url to redirect the user navigation to, once the form is submitted

      [ Top ]

      Properties

      Methods

      getAction


        string getAction( )

      Get the action id to be used by the url routing engine to build the target url

      Access:  public



      getController


        string getController( )

      Get the controller id to be used by the url routing engine to build the target url

      Access:  public



      getHiddenParameters


        array getHiddenParameters( )

      Get the array of parameters to be rendered as hidden parameters within the form

      Access:  public



      getLastRequest


        __Request getLastRequest( )

      Gets the last request in which this component was rendered in.

      This method is used by Lion in order to determine where to redirect the flow in case a server-side validation fails


      Access:  public



      getMethod


        string getMethod( )

      Get the submit method to be used by the current form component

      Access:  public



      getParameters


        mixed getParameters( )

      Get the parameters to be send within the form submit.

      Access:  public



      getRoute


        string getRoute( )

      Get the route id to be used by the url routing engine to build the target url

      Access:  public



      getUrl


        string getUrl( )

      Get the target url to redirect the navigation once the form has been submitted

      Access:  public



      setAction


        void setAction( string $action_code  )

      Set the action to be used by the url routing engine to build the target url


      Parameters:
      TypeNameDescription
      string $action_code

      Access:  public



      setController


        void setController( string $controller_code  )

      Set the controller to be used by the url routing engine to build the target url


      Parameters:
      TypeNameDescription
      string $controller_code

      Access:  public



      setHiddenParameters


        void setHiddenParameters( $hidden_parameters  )

      Set an array of parameters to be rendered as hidden parameters within the form


      Parameters:
      TypeNameDescription
      $hidden_parameters

      Access:  public



      setLastRequest


        void setLastRequest( &$request, __IRequest $request  )

      For internal usage only.

      Lion sets the last request in which this component was rendered in. Is used in case the server-side validation fails



      Parameters:
      TypeNameDescription
      &$request
      __IRequest $request

      Access:  public



      setMethod


        void setMethod( string $method  )

      Set the submit method, allowing same methods as the HTML form element.

      POST is the default method used by a form component



      Parameters:
      TypeNameDescription
      string $method

      Access:  public



      setParameters


        void setParameters( mixed $parameters  )

      Set a list of parameters (either an array or a comma-separated list) to be sent within the form submit.

      Parameters are also sent to the url routing engine to build the target url (if applicable)



      Parameters:
      TypeNameDescription
      mixed $parameters

      Access:  public



      setRoute


        void setRoute( string $route_id  )

      Set the route to be used by the url routing engine to build the target url


      Parameters:
      TypeNameDescription
      string $route_id

      Access:  public



      setTarget


        void setTarget( string $target  )

      Alias of __FormComponent::setUrl() method


      Parameters:
      TypeNameDescription
      string $target

      Access:  public



      setUrl


        void setUrl( string $url  )

      Set the url to redirect the user navigation to, once the form is submitted


      Parameters:
      TypeNameDescription
      string $url

      Access:  public