Download the PHP package fede91it/fof-nnrelation without Composer
On this page you can find all versions of the php package fede91it/fof-nnrelation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fede91it/fof-nnrelation
More information about fede91it/fof-nnrelation
Files in fede91it/fof-nnrelation
Package fof-nnrelation
Short Description FOF (Framework on Framework) support for many-to-many relations.
License
Informations about the package fof-nnrelation
F0F NNRelation
FOF NNRelation add support to many-to-many relations into FOF (Framework on Framework). In truth it's for FOF! It consist in a set of one F0FTableBehavior, one F0FModelBehavior and one F0FFormField. Add all these magic classes to get ready to use multiple relations (with pivot tables) in your F0F projects, with ease!
Requirements
- Joomla 3.x (it should works also with 2.5.x)
- FOF 2.3.x or greater (download Framework on Framework
Preparation
- Install
lib_f0f-nnrelation-1.0.0.tgz
library extension - Create a
dispatcher.php
file for your FOF component - Override the method
onBeforeDispatch
- Before calling
parent::onBeforeDispatch
include f0f-nnrelation in this way:
Usage
Table Behavior
In your form.form.xml
files you can use a new type of field called nnrelation
.
The name attribute must be the same of the name of the multiple relation you declared in the fof.xml
file.
In the exemple above, the multiple relation I want to manage is declared in this way:
As you see, you must enable the specific FOF behavior for the table in which you want to use the multiple relation.
In this example, the multiple relation will be automagically managed for all team
items that want to trace their players
. If you want to do viceversa, you have to declare the contrary teams
relation for the player
table, and enabling the behavior there. The names respects the standard FOF singular/plural conventions.
Model Behavior
In the front-end of your component you want to retrieve your multiple relations with ease. For this purpose you can enable the nnrelation
behavior for a view, and if here there is a multiple relation declared, all related items will be automagically retrieved.
Now in your list views, the $this->items
data object will contains a property named as the relation. Instead, you will have $this->item
in a item view.
Form Field
In your form.default.xml
files you can use a new type of field called nnrelation
.
Also in this case, the name of the field should reflect the name of the multiple relation declared in fof.xml
. The other attribures are inherited from the list
form type (see FOF documentation). The placeholder [ITEM:FOOBAR_PLAYER_ID]
is the name of the key value for your referred table, in the pivot table.
Form Header
Coming Soon...