Ferreteria/v2/usage/forms/creating

From Woozle Writes Code
< Ferreteria‎ | v2‎ | usage‎ | forms
Revision as of 02:33, 2 November 2015 by htyp>Woozle (extracted from parent page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

How to create a form for editing record-based data:

building the form object=

from Template:Vbzcart/code (function PageForm()): <php> $oForm = new fcForm_DB($this->Table()->ActionKey(),$this); $oField = new fcFormField_Num($oForm,'ID_BuyerCard'); $oCtrl = new fcFormControl_HTML($oForm,$oField,array('size'=>4)); </php> The first line creates a Form object, the next line creates a Field, and the third line assigns a Control to the Field. Adding additional fields and controls follows the format of the last 2 lines.

Certain field classes have additional options.

timestamps

<php> $oField = new fcFormField_Time($frm,'WhenEnt'); $oCtrl = new fcFormControl_HTML($frm,$oField,array('size'=>10)); $oField->Format('m/Y'); </php> This sets the format of the Control for the "WhenEnt" field based on the parameter string used by the PHP date() function – in this case, just the month (2 digits) and year (4 digits) are displayed.

dropdown selectors

<php> $oField = new fcFormField_Num($oForm,'ID_Place'); $oCtrl = new fcFormControl_HTML_DropDown($oForm,$oField,array()); $oCtrl->Records($this->PlaceTable()->GetData_forDropDown()); </php>

creating the display template

See Template:Vbzcart/code (function PageTemplate()) for a working example.