Jump to content

Grouping attributes: Difference between revisions

From NusaATK
 
(3 intermediate revisions by 2 users not shown)
Line 10: Line 10:


Sections will create a node level tabbed pane. For tabs as an attribute. See: [[Grouping attributes into tabs]]
Sections will create a node level tabbed pane. For tabs as an attribute. See: [[Grouping attributes into tabs]]
== Groups ==
"The addFieldSet() function was introduced to ATK on June 11, 2008. Prior to this the addGroup() function was used, but subsequently dropped from the core of ATK due to compatibility issues." See: [[Grouping attributes with addFieldSet]]
[strike]
Groups are a list of attributes that will be placed on 1 line with or without a border (html fieldset). Every group that you create will always appear on top of the other attributes!
Syntax:
<syntaxhighlight lang="php">
$this->addGroup("groupname",array("attrib1","attrib2"),<border>,"tab");
</syntaxhighlight>
in your node file use the following line to group two attributes with a surrounding box on the main tab:
<syntaxhighlight lang="php">
$this->addGroup("users",array("user_lastvisit","user_regdate"),TRUE,"main");
</syntaxhighlight>
and this to group two attributes without a surrounding box on the details tab:
<syntaxhighlight lang="php">
$this->addGroup("dates",array("user_level","user_posts"),FALSE,"details");
</syntaxhighlight>
'''Note:''' Groups only work with the steelblue theme at the moment!
[/strike]


== Sections ==
== Sections ==
Line 42: Line 15:
Sections always appear at the bottom.
Sections always appear at the bottom.


Syntax:  
Syntax for atkMetaNode based nodes:
 
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$this->add(new atkAttribute('test'),'default.section');
public static function meta(atkMetaPolicy $policy)
{
  $this->setSection(array("housenumber", "housenumber_suffix"), "default.address");
}
</syntaxhighlight>
</syntaxhighlight>


In your node file use the following line to add an acttribute to the section 'address':
Syntax for atkNode based nodes:  


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">

Latest revision as of 13:31, 12 February 2010

ATK Howto: Grouping attributes

Complexity: easy
Author: Sandy Pleyte <sandy at achievo.org>

List of other Howto's

Requirements

ATK 6.2+

Summary

In a node it's possible to group attributes for an edit form on 2 ways. With a group and a section.

Sections will create a node level tabbed pane. For tabs as an attribute. See: Grouping attributes into tabs

Sections

Groups a list with attributes on multiple lines which are collapsed by default. When you open a section it will retrieve the attributes with ajax. Sections always appear at the bottom.

Syntax for atkMetaNode based nodes:

public static function meta(atkMetaPolicy $policy)
{
  $this->setSection(array("housenumber", "housenumber_suffix"), "default.address");
}

Syntax for atkNode based nodes:

$this->add(new atkNumberAttribute('housenumber'), 'default.address');
$this->add(new atkAttribute('housenumber_suffix'), 'default.address');

The convention is: <tabname>.<sectionname>, in other words, the above places the attributes in the 'address' section of the default tab. Accepted notations:

  • ".address" - Put attribute in the address section if there are no tabs, or on the default tab
  • "billing" - Put attribute on the address tab
  • "billing.address" - Put attribute in the address section of the billing tab