The Links
- PHPSimpl 0.8.0 RC 1 Download w/Example (95Kb)
- Install Guide
- API and Examples
What? this kid has a life?
// Create the AddressHere is the output:
$myAddress = new Address;
// Get a list of all their addresses
$myAddress->SetValue('customer_id', $myCustomer->GetPrimary());
$myAddress->GetList();
// Display all their current addresses
if (count($myAddress->results) > 0){
foreach($myAddress->results as $address){
$myAddress->ResetValues();
$myAddress->SetValues($address);
$myAddress->MultiForm();
}
}
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:SetDisplay($fields) -> Boolean
SetHidden($fields) -> Boolean
SetOmit($fields) -> Boolean
SetOptions($options) -> Boolean
SetConfig($config) -> Boolean
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.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' => 'name@domain.com');
// 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');
$this->SetConfig($config);
}
}
// Create an RSVP Instance
$myRSVP = new RSVP;
// Display the form
echo '<form>';
$myRSVP->Form();
echo '<input name="submit" value="Save" type="submit">';
echo '</form>';