-
Notifications
You must be signed in to change notification settings - Fork 0
Callback Field
This field type allows you to get the field's contents using a callback, i.e. calling a static method of a specific class. The callback's results will appear as the field's contents.
This is typically useful for the following use cases:
- Rendering complex fields without creating a custom field class
- Including an external view in your form. Remember that the callback can do HMVC to call a view from the same or a different FOF-powered component.
- Adding non-static Javascript and CSS.
- Render input elements that are not possible with the other field types
The following attributes are used to specify the callback.
source_file
(optional) The PHP file which provides the class and method. It is given in the pseudo-URL format e.g. admin://components/com_foobar/helpers/mydata.php or site://components/com_foobar/helpers/mydata.php for a file relative to the administrator or site root directory respectively. You do NOT need to use this attribute for auto-loaded classes, e.g. Helper classes of any FOF-powered component.
source_class
(required) The fully qualified name of the PHP class to use, e.g. \Acme\Example\Admin\Helper\Select
source_method
(required) The static method of the PHP class to use, e.g. selectFoobars
.
FOF passes an indexed array of variables to the method. The array contains the following keys:
- model (type
FOF30\Model\DataModel
) The model of the form being rendered - form (type
FOF30\Form\Form
) The form currently being rendered - formType (type
string
) The type of the form being rendered, e.g. "read" or "edit" - fieldValue (type
mixed
) The value of the form field, if you are using aname
/name_from
attribute that corresponds to an existing field in your Model - fieldElement (type
SimpleXMLElement
) The XML source of the field being rendered
FOF (Framework on Framework) and its documentation are Copyright © 2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd.
FOF is Open Source Software, distributed under the GNU General Public License, version 2 of the license, or (at your option) any later version.
The FOF Wiki content is provided under the GNU Free Documentation License, version 1.3 of the license, or (at your option) any later version.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found on the GNU site.