Ferreteria/v2/usage/forms/creating: Difference between revisions
(format tweaks/fixes) |
(list of field & control types) |
||
Line 4: | Line 4: | ||
<php> | <php> | ||
$oForm = new fcForm_DB($this->Table()->ActionKey(),$this); | $oForm = new fcForm_DB($this->Table()->ActionKey(),$this); | ||
$oField = new | $oField = new fcFormField_<type>($oForm,'<field name>'); | ||
$oCtrl = new fcFormControl_HTML($oForm,$oField,array( | $oCtrl = new fcFormControl_HTML[_<type>]($oForm,$oField,array([HTML attributes]); | ||
</php> | </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. | 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. | ||
==Fields and Controls== | |||
{| width=100% | |||
== | |- | ||
| valign=top | | |||
Field types ({{ferreteria/code|forms/field.php}}): | |||
* '''fcFormField_Text''' | |||
* '''fcFormField_Num''' | |||
* '''fcFormField_Time''' | |||
** ->Format({{arg|date format}}) | |||
| valign=top | | |||
Control types ({{ferreteria/code|forms/ctrl.php}}): | |||
* '''fcFormControl_HTML''' - generic single-line text-editing field | |||
* '''fcFormControl_HTML_TextArea''' - multiline text | |||
* '''fcFormControl_HTML_Hidden''' - hidden values | |||
* '''fcFormControl_HTML_DropDown''' - drop-down chooser | |||
** ->Records({{arg|dataset}}); | |||
* '''fcFormControl_HTML_CheckBox''' - checkbox | |||
|} | |||
===Examples=== | |||
'''Timestamps''': | |||
<php> | <php> | ||
$oField = new fcFormField_Time($frm,'WhenEnt'); | $oField = new fcFormField_Time($frm,'WhenEnt'); | ||
Line 17: | Line 34: | ||
</php> | </php> | ||
This sets the format of the Control for the "WhenEnt" field based on the parameter string used by the PHP [http://php.net/manual/en/function.date.php date() function] – in this case, just the month (2 digits) and year (4 digits) are displayed. | This sets the format of the Control for the "WhenEnt" field based on the parameter string used by the PHP [http://php.net/manual/en/function.date.php date() function] – in this case, just the month (2 digits) and year (4 digits) are displayed. | ||
'''Dropdown selectors''': | |||
<php> | <php> | ||
$oField = new fcFormField_Num($oForm,'ID_Place'); | $oField = new fcFormField_Num($oForm,'ID_Place'); | ||
Line 23: | Line 41: | ||
$oCtrl->Records($this->PlaceTable()->GetData_forDropDown()); | $oCtrl->Records($this->PlaceTable()->GetData_forDropDown()); | ||
</php> | </php> | ||
== | ==Creating the Display Template== | ||
See {{vbzcart/code|dropins/orders/order.php#L1314}} (function PageTemplate()) for a working example. | See {{vbzcart/code|dropins/orders/order.php#L1314}} (function PageTemplate()) for a working example. |
Revision as of 15:20, 12 November 2015
How to create a form for editing record-based data:
from Template:Vbzcart/code (function PageForm()): <php> $oForm = new fcForm_DB($this->Table()->ActionKey(),$this); $oField = new fcFormField_<type>($oForm,'<field name>'); $oCtrl = new fcFormControl_HTML[_<type>]($oForm,$oField,array([HTML attributes]); </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.
Fields and Controls
Field types (Template:Ferreteria/code):
|
Control types (Template:Ferreteria/code):
|
Examples
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.