Create a Form View in KAS

Step by step on the basics of creating a Form in KAS

When creating a new Form Page in KAS, we need to specify the correct option types, 

The minimu required is F for Form, in the case of an edit F is enough, but when inseting we also need the case A - Add

For example, the existing section of Add Affiliate page in stats looks like this 

/*
F - Form
A - Add
​*/

$stats->setOption("ADD AFFILIATE,AGREGAR AFILIADO,AJOUTER AFFILIER","aside","5","FA");

 

Once the section is created we can create the PHP file in the designated location, like "themes/theme/Section/NEW_PAGE.php"

The new page will have the following basic structure:

 

$nexturl = '';//next URL
$dbtable = '';// Table Name
$idfield = '';//ID Field
$case_title = '';//Title of tha page
$message = 'Message after submitting thre form';

 

$next_url can have different configurations, please refer to How to go to a next page after saving to learn the right usage.

Then we need to include the file that generates the HTML form, since the form has a beginning and an end and in-between all the fields are added, we need to specify if we are opeing or closing the form.

 

$form = 'open';
include('core/form_view.php');

 

After opening the form, we can now create add Fields to the form, at this stage we can use divsions to create columns, using the class "form_div", this class will create columns of 50% the width and float left.

To change from row to row we can add an empty division with class "clearFloat"

 

<div class="form_div">
     //Left Column
</div>
<div class="form_div">
       //Right Column
</div>

<div class="floatLeft"></div>

 

In many cases we can add a Save Button outside the columns in the upper right corner of the page. To do so add a field "button:right" outside the divsions, and to add another one at the bottom we add a "button" filed after the divsions.

Then we can close our form and include the file that generates the HTML to close the form.

 

<?php addField('button:right','save', translate('ITEM','ITEM','ITEM')); //save, modify, create, add, update ?>
<div class="form_div">
     //Left Column
</div>
<div class="form_div">
       //Right Column
</div>

<div class="floatLeft"></div>
<?php 
addField('button','save', translate('ITEM','ITEM','ITEM')); //save, modify, create, add, update 
$form = 'close';
include('core/form_view.php');
?>

 

With our form created we can add Fields inside each column using the addField() function, each field can have different settings and many may require an option type, like switches, drag and drop fields, etc.

 

<?php 
$nexturl = '';//next URL
$dbtable = '';// Table Name
$idfield = '';//ID Field
$case_title = '';//Title of tha page
$message = 'Message after submitting thre form';

$form = 'open';
include('core/form_view.php');

//save, modify, create, add, update
addField('button:right','save', translate('ITEM','ITEM','ITEM'));  ?>
<div class="form_div">
<?php
    addField(array(type  => 'text',label => 'NAME',name => 'NAME'));
    addField(array(type  => 'text',label => 'LAST NAME',name => 'LNAME')); 
?>
</div>
<div class="form_div">
<?php
    addField(array(type  => 'email',label => 'EMAIL',name => 'EMAIL'));
    addField(array(type  => 'password',label => 'PASSWORD',name => 'PASSWORD'));
?>
</div>

<div class="floatLeft"></div>
<?php 
addField('button','save', translate('ITEM','ITEM','ITEM')); //save, modify, create, add, update 
$form = 'close';
include('core/form_view.php');
?>

 

 

 

Get a Quote

Get a Quote