Web Form Widgets
Widgets are PHP wrappers of web form input fields. They process data from a single (rarely multiple) HTML input field(s). Widgets can be explicitly created in the source, but preferred approach is to map them in a miDataManager subclass.
In template widgets represent the whole input box (including HTML).
For simple widgets in the templates is used this construct:
<span>
<input type="text" name="UserLogin" value="%%USERLOGIN%%" />
</span>
For ordinary widgets:
<span>%%USERLOGIN%%</span>
* Map widgets
<?php
class wsProductsDataManager extends miDataManager {
protected $_dataFields = array(
array(
'field' => 'miWebFormFieldText',
'data' => 'ProductID'
),
array(
'field' => 'miWebFormWidgetSelect',
'data' => 'ProductColor'
),
array(
'field' => 'miWebFormWidgetText',
'data' => 'ProductName',
)
);
}
?>
<?php
class wsProductsDataManager extends miDataManager {
public function initWebForm(miWebForm $form)
{
parent::initWebForm($form);
$productOptions = miUtil::getDBArray('SELECT ProductOptionID, ProductOptionName FROM ProductOptions', 'ProductOptionID', 'ProductOptionName');
$productOptionsSelect = new miWebFormWidgetSelect($form);
$productOptionsSelect->setFieldName('ProductOptions');
$productOptionsSelect->setOptions($productOptions);
$form->addMainPageElements(array('%%PRODUCTOPTIONS%%' => $productOptionsSelect->getEditableControl()));
}
}
?>