When creating a new Form Page in KAS, we need to specify the correct option types,
F enables a Form View. Use FA for a normal Add form (A selects INSERT) and FU for a normal Edit form (U selects UPDATE). Add H for a colorPicker field: FAH or FUH.
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 "kas/includes/SECTION/NEW_PAGE.php" for a Core section; theme paths are for project-specific pages
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';
$nexturl 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="clearFloat"></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="clearFloat"></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="clearFloat"></div>
<?php
addField('button','save', translate('ITEM','ITEM','ITEM')); //save, modify, create, add, update
$form = 'close';
include('core/form_view.php');
?>
Current Core clarification
Use the native FAH form with a colorPicker field. Set $nexturl before opening form_view.php; use clearFloat to clear form columns.