Ferreteria/v2/usage/forms/displaying: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v2‎ | usage‎ | forms
Jump to navigation Jump to search
m (Woozle moved page Ferreteria/pieces/forms/displaying to Ferreteria/usage/forms/displaying: this should be a usage guide)
(No difference)

Revision as of 12:48, 4 March 2017

displaying a form

See Template:Vbzcart/code for a working example of a full-page form, and Template:Vbzcart/code for building a template.

template example

<php>

   private $tpPage;
   protected function PageTemplate() {

if (empty($this->tpPage)) { $sTplt = <<<__END__

</php>...<php>

QuoFinal
ID:ID
Status:Status
Cart:Cart
Ship $ quoted:QuoShip
Final $ quoted:
AmtMerchBalBtnsLineRecalcLine

__END__; $this->tpPage = new fcTemplate_array('','',$sTplt); } return $this->tpPage; </php>

without templates

It can also be done without templates by retrieving the control and asking it to render itself:<php> $oForm = $this->EditForm(); // retrieve the form object (build it if needed) $oForm->LoadRecord(); // copy values from {memory image of record} to {form fields} $ftTag = $oForm->ControlObject('Name')->Render($doEdit); $ftCust = $oForm->ControlObject('ID_Cust')->Render($doEdit); $ftAddr = $oForm->ControlObject('ID_Addr')->Render($doEdit); $ftName = $oForm->ControlObject('ID_Name')->Render($doEdit); </php> ...(and so on), then manually plugging the rendered controls into the desired output format:<php> $out .= <<<__END__

...

ID:$id
Tag:$ftTag
Status:$ftStatus
Customer:$ftCust
Address:$ftAddr
Name:$ftName

__END__; </php> ...but note that calling LoadRecord() causes the Field objects to return TRUE from IsChanged() if the loaded value is non-NULL. This overrides POST data in $oForm->Save(), so presumably you'll need to build the update query manually or else clear the form fields somehow (currently not supported, but maybe it should be).