Jump to content

AtkListAttribute: Difference between revisions

From NusaATK
m small typo
Harrie (talk | contribs)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{attribute}}
The '''atkListAttribute''' is used for list several options in a select. In database it can be a varchar.
The '''atkListAttribute''' is used for list several options in a select. In database it can be a varchar.


== Params ==
== Params ==
The constructor of the atkBoolAttribute has the following params:
The constructor of the atkListAttribute has the following params:
  atkListAttribute (mixed $name, mixed $optionArray, [mixed $valueArray = ""], [mixed $flags = 0])
  atkListAttribute (mixed $name, mixed $optionArray, [mixed $valueArray = ""], [mixed $flags = 0])


Line 22: Line 24:
  $this->add(new atkListAttribute("fruit", array("orange", "lemon", "grape"), array(1,2,3), AF_LIST_OBLIGATORY_NULL_ITEM);
  $this->add(new atkListAttribute("fruit", array("orange", "lemon", "grape"), array(1,2,3), AF_LIST_OBLIGATORY_NULL_ITEM);
The same, but instead of save fruit names to database, it will save 1, 2 or 3. Also, there will be a default option that will save null to database.
The same, but instead of save fruit names to database, it will save 1, 2 or 3. Also, there will be a default option that will save null to database.
(in a [[metanode]] meta-method):
  $policy->setTypeAndParams("fruit", "atklistattribute", array(array("orange", "lemon", "grape"), array(1,2,3)));
The same but for the atkMetaNode, and without the flags (you could add them as an extra parameter, but it's considered bad practice and you should add flags with an additional $policy->addFlag(s) call).


== See also ==
== See also ==
* [[ATK_Attribute_Flags#atkListAttribute|atkListAttribute specific attribute flags]]
* [[ATK_Attribute_Flags#atkListAttribute|atkListAttribute specific attribute flags]]
[[Category:Attributes]]
[[Category:Attributes]]

Latest revision as of 14:38, 29 July 2010

Attribute: atkListAttribute

API docs | Flags

List of other attributes

atkListAttribute screenshot

The atkListAttribute is used for list several options in a select. In database it can be a varchar.

Params

The constructor of the atkListAttribute has the following params:

atkListAttribute (mixed $name, mixed $optionArray, [mixed $valueArray = ""], [mixed $flags = 0])
  • name String

Name of the attribute (the same as the fieldname used in the database)

  • optionArray Array

Array with options to be show. If valueArray is not passed, or null, it will be save at database too.

  • valueArray (optional) Array

Array with values to be save to database.

  • flags (optional) Integer

Flags for the attribute. For more information about flags, please checkout the flags section.

Examples

(in a node constructor):

 $this->add(new atkListAttribute("fruit", array("orange", "lemon", "grape"));

Adds a field fruit to the node. In the admin this will be displayed as select with "orange", "lemon", "grape".

$this->add(new atkListAttribute("fruit", array("orange", "lemon", "grape"), array(1,2,3), AF_LIST_OBLIGATORY_NULL_ITEM);

The same, but instead of save fruit names to database, it will save 1, 2 or 3. Also, there will be a default option that will save null to database.


(in a metanode meta-method):

 $policy->setTypeAndParams("fruit", "atklistattribute", array(array("orange", "lemon", "grape"), array(1,2,3)));

The same but for the atkMetaNode, and without the flags (you could add them as an extra parameter, but it's considered bad practice and you should add flags with an additional $policy->addFlag(s) call).

See also