Banner image SITE-LANGUAGE-en-ICON BROWSER-LANGUAGE--IMAGE
Content / help / biscuits-tools .. concise-view << previous next >>

This is the older method of form generation usign a PHP class

Forms can be rendered by using the tools class but we now prefer to use HTML directly written into a view file in conjunction with the new form javascript biscuits-forms.js.
Our biscuits-forms.js functions pick up data- attributes to define the validation to do for each form input or textarea.

These are still commonly used throughout the biscuits engine functions

Examples

Modify an existing row


       $this->findClass('tools_1b');
        $this->tools = new tools();
        
        $formSpec   =   array(
            'form_id'           =>  'edit_transaction',
            'id'                =>  $transactionId,
            'table'             =>  'et_sales',
            'access_allowed'    =>  $access_allowed,
            
            'fields'    =>   array(
                'account'      =>  'Account Name',
                'transactionId'     =>  'Transaction ID',
                
                'description'       =>  'Description',
                'amount'            =>  'Amount',
                'display_date_paid' =>  'Date Paid',
                ),
            
            'fldReadOnly'      =>  array(
                'account'       =>  true,
                'transactionId' =>  true,
                'display_date_paid' => true,
                ),
            'set_values'    =>  array(
                'userid'        =>  $row['userid'],                
                'account'       =>  $account['username'],
                'transactionId' =>  $transactionId,
                
                'display_date_paid'  =>  date("D dS M Y ",$row['date_paid']),
                ),
            
            );
        
        $this->tools->database_form($formSpec);
        $this->pageFoot();
 

        

The DB pdate

Biscuits forms post the form data on submission back to the same page. The tools.php class detects that post data has been submitted and takes care of the DB update.
This is detected by the inclusion of a hidden form input in all forms.

            if (isset($_POST['tools-form'])) {
                        if ($_POST['tools-form'] == $this->form_id) {
                // Remember! the form may not validate and so can be posted again after amending the data. 
                $this->processSubmission();
                ...
                ...

               $this->doFormSQL();
            





iBiscuits LOGO