Nick DeNardis

User experience, code, higher education, analytics and accessibility.

A More Centered API

Its been a while but we have been working hard on an API that is going to withstand the test of time. This will make Simpl more expendable and not require as many application code level changes in the future.

These function have been added to the Form() Class:

SetDisplay($fields) -> Boolean
SetHidden($fields) -> Boolean
SetOmit($fields) -> Boolean
SetOptions($options) -> Boolean
SetConfig($config) -> Boolean

They can make the DbTemplate and Form classes a lot easier to work with. Here is an example of how to declare a class with these new functions:

class RSVP extends DbTemplate {
* Class Constuctor
* @param $data array
* @return null
function __construct($data=''){
// Setup the required fields
$required = array('first_name', 'last_name', 'email', 'phone', 'is_attending');
// Setup their labels
$labels = array('first_name' => 'First Name', 'last_name' => 'Last Name', 'email' => 'E-Mail', 'is_attending' => 'Attending');
// Setup the examples
$examples = array('email' => ''); // Call the Parent Constructor
$this->DbTemplate($data, $required, $labels, $examples, 'rsvp', '', 'my_database'); // Set the Display
$display = array('first_name', 'last_name', 'email', 'phone', 'is_attending');
$this->SetDisplay($display); // Add a validation Type
$this->Set('validate','homepage', 'url'); // Set the defaults
$defaults = array('is_attending' => 1);
$this->SetDefaults($defaults); // Set the Options
$options = array('is_attending' => array('1' => 'Yes', '0' => 'No'));
$this->SetOptions($options); // Set the Config
$config = array('is_attending'=>'radio');

Now the display and the config information follow the class where ever it is used. Also the default values can be used to set up the form before the user enters any information.Example of this being used on the page:

// Create an RSVP Instance
$myRSVP = new RSVP;// Display the form
echo '

echo '';
echo '