Home
$arrayParams 'errormessage'
- Details
Passing 'errormessage=>'some message' will replace the default error message when there is a validation error.
addValidation valueNotInDBTable
- Details
before you can use any type of table validation you will need to give that element a db link.
sample:
$this->siteForms->boundElements['username']->db = $this->db;
$this->siteForms->boundElements['username']->addValidation('valueNotInDBTable',array('table'=>'users','col'=>'username'));
If you wanted to allow the user to change their username in a form you would want to specify the original value to be allowed in case they don't change their username.
$this->siteForms->boundElements['username']->addValidation('valueNotInDBTable',array('table'=>'users','col'=>'username','ignoreorignalvalue'=> $this->web_helper->getFormValue("oldusername","","Username")) );
The olderuser element would look like this:
$this->siteForms->createElement('oldusername',false,'oldusername',"", "UserName");
$this->siteForms->boundElements['oldusername']->form_web_type = "hidden";
$this->siteForms->boundElements['oldusername']->col_name='username';
$this->siteForms->boundElements['oldusername']->auto_populate_db = true;
Usages
- Details
Generally you will want to setup you form in the controller and call render in the view. Some times for very elaborate forms you may not want to call render of the entire form but just the elements in a certain order.
Basic use:
Here is an example of security question controller:
//Set the table you want to use, the primary key that will be used for updating it
$this->siteForms->setTableName('users');
$this->siteForms->setPKName('id');
$this->siteForms->createElement('id',true,'id',"", "Numeric");
//bind the elements
$this->siteForms->createElement('recovery_q1',true,'',"", "AlphaNumeric");
$this->siteForms->boundElements['recovery_q1']->addValidation('notEmpty',array());
$this->siteForms->createElement('recover_an1_enc',true,'',"", "AlphaNumeric");
$this->siteForms->boundElements['recover_an1_enc']->addValidation('notEmpty',array());
$this->siteForms->createElement('save_btn',false);
//when you first load you will need to set this
$this->siteForms->setTableAction('edit');
//after the form is submitted you'll need to do this
$this->siteForms->setTableAction('update');
//to validate the form do this:
$GoodData = $this->siteForms->bindAndFilter();
//describe their web attributes
$this->siteForms->boundElements['recovery_q1']->form_web_type = "select";
$this->siteForms->boundElements['recovery_q1']->form_label = "Recovery Question 1";
$this->siteForms->boundElements['recovery_q1']->form_cntrl_values = array("what's you pets name?"=>"what's you pets name?","What city were you born in"=>"What city were you born in?");
$this->siteForms->boundElements['recover_an1_enc']->form_web_type = "text";
$this->siteForms->boundElements['recover_an1_enc']->form_label = "Answer to question 1";
$this->siteForms->boundElements['save_btn']->form_web_type = "submit";
$this->siteForms->boundElements['save_btn']->form_label = "";
$this->siteForms->boundElements['save_btn']->form_value = "Save";
//load the data into the form will use the PKName you set and the value you pass to look it up
$this->siteForms->dbLoadSelectTableSingleRow($this->user->user_id); // SQL sees it as id=$this->user->user_id
To render this form in the view controller we call the render function:
echo $this->renderForm();
Hello World
- Details
The best way to start any new language or frame is Hello World.
First the file structure.
What is the app name going to be called. This is not really the fancy name but what your internal app will be called. For example: the main app is called site. For hello world we will call it helloworld.
in you apps folder make a folder called helloworld.
in your new folder you will want to make at the minimal a file called helloworld.php
Page 6 of 40