PHOCOA PHP Framework

This page demonstrates the use of radio buttons in conjunction with WFDynamic.

A WFRadioGroup is a meta-widget and is never used directly in template files. The WFRadioGroup is solely to provide a single interface to the programmer for accessing the value represented by an arbitrary number of WFRadio's. In this example, the WFRadio's are created dynamically by the WFDynamic widget.

The use of this setup allows for the dynamic, automatic creation of radio buttons based on items in an array in your model. It is a powerful capability, requiring minimal setup. See the WFDynamic docs to read about all of the options.

You will notice that some minimal coding is required for this setup. This is required to tell the WFDynamic where to get the values for the each radio's label and value represented.

NOTE: the parentFormID property is currently named poorly. It really just means "parent widget" and will be changed in the future. Don't let it confuse you.






.tpl file

{WFDynamic id="radios"}

.instances file

$__instances = array(
	'radios' => array('class' => 'WFDynamic', 'children' => array()),
	'radioGroup' => array('class' => 'WFRadioGroup', 'children' => array()),
);

.config file

$__config = array(
	'radios' => array(
		'properties' => array(
			'arrayController' => '#module#cities',
			'parentFormID' => 'radioGroup',
			'oneShotMode' => true,
			'widgetClass' => 'WFRadio',
		),
	),
	'radioGroup' => array(
		'properties' => array(
			'value' => '4',
		),
		'bindings' => array(
			'value' => array(
				'instanceID' => 'person',
				'controllerKey' => 'selection',
				'modelKeyPath' => 'cityID',
			),
		),
	),
);

Module Code

    function radios_PageDidLoad($page, $params)
    {
        $radioDynamicOptions = array(
                                    'label' => array(
                                        'bind' => array(
                                            'instanceID' => '#current#',
                                            'controllerKey' => '',
                                            'modelKeyPath' => 'name'
                                            )
                                        ),
                                    'selectedValue' => array(
                                        'custom' => array(
                                            'iterate' => true,
                                            'keyPath' => '#identifier#'
                                            )
                                        )
                                    );
        $page->outlet('radios')->setWidgetConfig($radioDynamicOptions);
    }

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) 2014 Alan Pinstein. All Rights Reserved.