Ajax: Difference between revisions
No edit summary |
|||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{howto|Easy|[[Ivo Jansch]] | {{howto|Easy|[[Ivo Jansch]] , [[Harrie Verveer]] }} | ||
This howto demonstrates the Ajax features that are built into ATK. | This howto demonstrates the Ajax features that are built into ATK. | ||
= Dependencies between attributes = | |||
If you have attributes that depend on the value of another attribute, you can use the following construct: | If you have attributes that depend on the value of another attribute, you can use the following construct: | ||
| Line 27: | Line 27: | ||
(For more details on filtering atkManyToOneRelations, see the '[[Filter the items in an atkManyToOneRelation]]' howto.) | (For more details on filtering atkManyToOneRelations, see the '[[Filter the items in an atkManyToOneRelation]]' howto.) | ||
= Complexer dependencies = | = Complexer dependencies = | ||
There's an additional set of features that can be achieved using attribute dependencies. See the [[Attribute dependency callbacks]] howto for more information on this. | There's an additional set of features that can be achieved using attribute dependencies. See the [[Attribute dependency callbacks]] howto for more information on this. | ||
Latest revision as of 10:00, 11 March 2011
|
ATK Howto: Ajax
|
This howto demonstrates the Ajax features that are built into ATK.
Dependencies between attributes
If you have attributes that depend on the value of another attribute, you can use the following construct:
$attribute1->addDependee("attribute2");
Where $attribute1 is the master attribute, in other words, the attribute that triggers the update of other attributes., and "attribute2" is the name of the attribute that gets reloaded when the master changes.
Other than that, there's no need to do anything different from what you were used to without AJAX. For example, let's see how this is implemented in achievo's quotation module:
$org = &$this->add(new atkManyToOneRelation("organization_id","organization.organization"));
$org->addDependee("contact");
$con = &$this->add(new atkManyToOneRelation("contact","organization.contact"));
$con->addDestinationFilter("company = '[organization_id.id]'");
These 4 lines make sure that the 'contact' m2o only shows contacts that belong to the organization selected in the 'organization_id' attribute. If you whould not use AJAX, you whould probably use the same lines as stated above, except for the 'addDependee' part. This one line takes care of reloading the values in the 'contact' m2o-dropdown when the organization m2o-dropdown changes. Also the initial values in the 'contacts' dropdown is taken care of, due to the fact that all 'dependee' fields will be refreshed when the page is loaded.
(For more details on filtering atkManyToOneRelations, see the 'Filter the items in an atkManyToOneRelation' howto.)
Complexer dependencies
There's an additional set of features that can be achieved using attribute dependencies. See the Attribute dependency callbacks howto for more information on this.