PHOCOA PHP Framework

This is a simple form example. Notice that there is NO CODE that needs to be written to support this form. It is linked to the data object without any code. PHOCOA automatically grabs the data from the object and puts it in the form, and then puts all data back into the object when the form is submitted. Also, note how the widgets maintain their state perfectly across requests.

Name
Creation DTS2017 Mar Fri
Favorite Colors
City
Bio
Gender

Person data

Notice how the data of the Person object is updated automatically when you submit the form WITHOUT ANY CODE.

Person Object
(
    [id] => 1
    [bio:protected] => I am 31 and a Libra.
    [name:protected] => Alan Pinstein
    [creationDTS:protected] => 1490378146
    [city:private] => City Object
        (
            [id] => 2
            [name] => Atlanta
        )

    [favoriteColors:protected] => Array
        (
            [0] => blue
            [1] => red
        )

    [gender:protected] => male
    [wealth:protected] => 2500.25
)

.tpl File


{WFForm id="form"}
<table border="1" cellpadding="5" cellspacing="0">
    <tr><td>Name</td><td>{WFTextField id="name"}</td></tr>
    <tr><td>Creation DTS</td><td>{WFLabel id="creationDTS"}</td></tr>
    <tr><td>Favorite Colors</td><td>{WFSelect id="selectMultiple"}</td></tr>
    <tr><td>City</td><td>{WFSelect id="selectOne"}</td></tr>
    <tr><td>Bio</td><td>{WFTextArea id="textarea"}</td></tr>
    <tr><td>Gender</td><td>{WFView id="radioOne"} {WFView id="radioTwo"}</td></tr>
</table>
{WFSubmit id="action1"}
{/WFForm}


.instances File

$__instances = array(
    'form' => array('class' => 'WFForm', 'children' => array(
        'name' => array('class' => 'WFTextField', 'children' => array()),
        'creationDTS' => array('class' => 'WFLabel', 'children' => array()),
        'selectOne' => array('class' => 'WFSelect', 'children' => array()),
        'radioButtons' => array('class' => 'WFRadioGroup', 'children' => array(
            'radioTwo' => array('class' => 'WFRadio', 'children' => array()),
            'radioOne' => array('class' => 'WFRadio', 'children' => array()),)
            ),
        'selectMultiple' => array('class' => 'WFSelect', 'children' => array()),
        'textarea' => array('class' => 'WFTextArea', 'children' => array()),
        'action1' => array('class' => 'WFSubmit', 'children' => array()),)
    ),
);

.config File

$__config = array(
	'form' => array(
		'properties' => array(
			'method' => 'post',
		),
	),
	'name' => array(
		'bindings' => array(
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'name',
			),
		),
	),
	'creationDTS' => array(
		'properties' => array(
			'formatter' => '#module#creationDTSFormatter',
		),
		'bindings' => array(
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'creationDTS',
			),
		),
	),
	'selectOne' => array(
		'bindings' => array(
			'contentLabels' => array(
				'instanceID' => 'cities',
				'controllerKey' => 'arrangedObjects',
				'modelKeyPath' => 'name',
			),
			'contentValues' => array(
				'instanceID' => 'cities',
				'controllerKey' => 'arrangedObjects',
				'modelKeyPath' => 'id',
			),
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'cityID',
			),
		),
	),
	'radioButtons' => array(
		'bindings' => array(
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'gender',
			),
		),
	),
	'selectMultiple' => array(
		'properties' => array(
			'multiple' => true,
			'visibleItems' => 6,
		),
		'bindings' => array(
			'values' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'favoriteColors',
			),
			'contentValues' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'colorValues',
			),
		),
	),
	'textarea' => array(
		'bindings' => array(
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'bio',
			),
		),
	),
	'action1' => array(
		'properties' => array(
			'label' => 'Submit Form and Re-Display',
		),
	),
	'radioTwo' => array(
		'properties' => array(
			'selectedValue' => 'male',
			'label' => 'Male',
		),
	),
	'radioOne' => array(
		'properties' => array(
			'label' => 'Female',
			'selectedValue' => 'female',
		),
	),
);

Module Code

none

Examples

Cookbook
  Widgets
  Bindings
  Pagination
  Formatters

Basic Examples
  Email
  Skin Browser
  Forms
  Regex Tester

AJAX Examples
  Infrastructure

  (YUI Examples)
  AutoComplete
  ColorPicker
  Menu
  Tree View
  Tab View
  Container

Appcelerator Integration
  Demo
Copyright (c) 2017 Alan Pinstein. All Rights Reserved.