Ajax
|
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->addDependency("attribute2");
After that you don't need to do anything else than you whould do without AJAX. For example, let's see how this is implemented in achievo's quotation module:
$organization_attribute = &$this->add(new atkManyToOneRelation("organization_id","organization.organization" , AF_OBLIGATORY|AF_RELATION_AUTOLINK|AF_SEARCHABLE));
$organization_attribute->addDependee("contact");
$contact_attribute = &$this->add(new atkManyToOneRelation("contact","organization.contact", AF_OBLIGATORY|AF_HIDE_LIST));
$contact_attribute->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.
Autocompletion
Recordlist navigation
Note: This page uses features that require version 5.7 or higher.