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();