Changes between Version 7 and Version 8 of DolphinTutorialMyFirstModule


Ignore:
Timestamp:
Jan 29, 2010, 6:24:08 AM (14 years ago)
Author:
AlexT
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DolphinTutorialMyFirstModule

    v7 v8  
    709709The form description array can be described the following way: 
    710710 
    711  * form_attrs are regular HTML attributes which will be added to the <form> tag. 
    712  * params are special function parameters. This can have several parameters, but most important is the db sub-array which describes the table to save form data to. 
    713  
    714     * table is the database table name to save data to 
    715     * key is the database primary key field (it is used to update data) 
    716     * submit_name is the name of the submit html form element and is used to determine automatically when the form is submitted. 
    717  
    718  * the inputs array describes every form element, and each element consists of the following fields: 
    719  
    720     * type is input type, like text, textarea, etc 
    721     * name is input the type name it also must match database field name 
    722     * caption is the indicated form element name 
    723     * required displays a red asterisk near the caption. Please note that it displays a red asterisk only. No real checking for mandatory fields is made if this field is true. For real checking see below. 
    724     * checker describes the checker function for the field. This is a place where real checking takes place. 
    725           * func is the checking function, like length, preg, avail, etc. 
    726           * params are checking function params. Params varies depending on the exact function. 
    727           * error is the message to display near the field if checking failed. 
    728     * db describes the database field to save input data to. The most important is the following parameter: 
    729           * pass is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be Xss, XssHtml, Int, Float, Date, etc. 
     711'''form_attrs''' are regular HTML attributes which will be added to the''' <form>''' tag. 
     712 
     713'''params''' are special function parameters. This can have several parameters, but most important is the '''db''' sub-array which describes the table to save form data to. 
     714 
     715       * '''table''' is the database table name to save data to 
     716       * '''key''' is the database primary key field (it is used to update data) 
     717       * '''submit_name''' is the name of the submit html form element and is used to determine automatically when the form is submitted. 
     718 
     719the '''inputs''' array describes every form element, and each element consists of the following fields: 
     720 
     721       * '''type''' is input type, like '''text''', '''textarea''', etc 
     722       * '''name''' is input the type name it also must match database field name 
     723       * '''caption''' is the indicated form element name 
     724       * '''required''' displays a red asterisk near the caption. Please note that it displays a red asterisk only. No real checking for mandatory fields is made if this field is true. For real checking see below. 
     725       * '''checker''' describes the checker function for the field. This is a place where real checking takes place. 
     726              * '''func''' is the checking function, like '''length''', '''preg''', '''avail''', etc. 
     727              * '''params''' are checking function params. Params varies depending on the exact function. 
     728              * '''error''' is the message to display near the field if checking failed. 
     729       * db describes the database field to save input data to. The most important is the following parameter: 
     730              * '''pass''' is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be '''Xss''', '''XssHtml''', '''Int''', '''Float''', '''Date''', etc. 
    730731 
    731732This doesn't describe all the possible values of this array. For a complete list please refer to the '''inc/classes/BxDolForm.php''' file. 
    732733 
     734Let's come back to the '''actionAdd''' function. First, we check that only members and admins can add blog posts. We have already described the '''$GLOBALS['logged']''' array. Then '''pageStart''' tells us that output will be below. Then, we import the '''BxTemplFormView''' class and create a class instance by passing the form description array to the class constructor. '''initChecker''' initializes the checker function. It is needed if the form was submitted with wrong values. Then, if the form was not submitted or it has invalid data the the form will be displayed ('''getCode''' function is called). Otherwise we will save the submitted data by calling the '''insert''' form function. Before saving, we added additional database fields, and after successful saving we are redirected to the post view page (which we will create in the next step). This page displays when we call the '''pageCode''' function. 
     735 
     736You can already try the form functionality, and see in the database if the data was saved. Let's proceed to the blog view page, to be able to view submitted data in a user friendly manner. 
     737 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub