-
Notifications
You must be signed in to change notification settings - Fork 0
Model Header
Works like the Searchable Header field but instead of hard-coding the options it reads them from a FOF DataModel class.
The additional attributes are:
You can set the following attributes on top of those of the Searchable header field type's:
-
model The name of the Model class to use. You can use one of the following notations
- A plain name e.g.
Itemsto load the Items model class from your component's current namespace - A dotted component.name notation e.g.
com_example.Itemsto load the Items model class from the com_example component In both cases FOF will go through the component's Container to get the Factory and ask it to instantiate the model name you specified.
- A plain name e.g.
-
key_field The name of the field in the model's results which is used as the key value of the drop-down
-
value_field The name of the field in the model's results which is used as the label of the drop-down
-
translate Should the value field's value be passed through JText::_() before being displayed?
-
apply_access Should we respect the view access level, if an access field is present in the model
-
with A comma-separated list of relations to eager load. If it's not specified the model's default will be used. You can set an empty attribute to prevent eager loading of relations.
-
none The placeholder to be shown if the value is not found in the data returned by the model. This placeholder goes through JText, so you can use a language string if you like.
-
format See the Text Field
-
show_link See the Text Field
-
url See the Text Field
In order to filter the model you can specify <state> sub-elements in the field's definition:
<state key="state_key">value</state>Where state_key is the key of a state variable and value is its value. For instance, you could have something like:
<state key="foobar_category_id">123</state>A full example of a Model field:
<header
name="example" type="Model"
model="com_example.Items"
key_field="example_item_id"
value_field="title"
translate="false"
apply_access="true"
none="COM_FOOBAR_ITEMS_MSG_NO_EXAMPLE_ITEM_SELECTED"
>
<state key="enabled">1</state>
<state key="language"><![CDATA[en_GB, *]]></state>
</header>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.