Jump to content

AtkAttribute

From NusaATK

Attribute: atkAttribute

API docs | Flags

List of other attributes

atkAttribute screenshot

Description

The atkAttribute is the most basic attribute that exists. It can be used to represent a basic textfield (varchar/string) in the database.

Params

The constructor of the atkAttribute has the following params: atkAttribute($name, $flags = 0, $size = 0)

  • name String
Name of the attribute (unique within a node, and for most attributes, corresponds to a field in the database.
  • flags (optional) int
Flags for the attribute. For more information about flags, please checkout the flags section.
  • size (optional) mixed
The max. number of characters that can be entered. If not specified, or set to 0, the max. size is automatically 
retrieved from the table metadata.

By default, the size of the edit box is the same as the maximum
number of chars that can be entered (as long as it fits on
screen). You can however pass an array of 2 or 3 numbers instead
of a single number. In this case, the array is interpreted as
follows:
- $size[0] - The maximum size that can be entered
- $size[1] - The size of the input box in add/edit forms
- $size[2] - The size of the search box

If $size[2] is not specified, $size[1] will be used instead.
If $size[1] is not specified, or the passed value is not an
array, all 3 sizes will default to the first value.

Note: The sizes that are actually used depend both on the
specified size and the size of the field in the database.
Usually, these are the same. In the case they differ, the
smallest of the 2 will be used.

Examples

(in a node constructor):

$this->add(new atkAttribute("firstname"));

Adds a field 'firstname' to the node

$this->add(new atkAttribute("firstname",AF_OBLIGATORY|AF_HIDE_LIST));

Does the same, but mades the field required to fill in and hides it's value in the list

$this->add(new atkAttribute("firstname",AF_OBLIGATORY|AF_HIDE_LIST,10));

Makes the maximum input for the field 10 characters, even when the database field is larger