AtkDummyAttribute: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 43: | Line 43: | ||
Jane | Jane | ||
=== FAQ === | |||
<strong>Where are the attribute labels?</strong> | |||
The atkDummyAttribute defaults to no label. If you wish to reinstate the label, configure it as follows: | |||
<syntaxhighlight lang="php"> | |||
public static function meta(atkMetaPolicy $policy) { | |||
$policy->add("additional_price", "atkDummyAttribute", array(null, AF_DUMMY_SHOW_LABEL)); | |||
} | |||
</syntaxhighlight> | |||
(Do not attempt to set the flag using the third argument to add(), and do not attempt to remove the label afterwards; it must be passed through to the atkDummyAttribute constructor, as above.) | |||
=== See Also === | === See Also === | ||
* [[Usage without DB I/O Polymorphism]] - prevent an attribute from attempting to access the database; useful if you want to create a dummy "structured" attribute, such as a date attribute | * [[Usage without DB I/O Polymorphism]] - prevent an attribute from attempting to access the database; useful if you want to create a dummy "structured" attribute, such as a date attribute | ||
Revision as of 09:21, 14 August 2008

it is possible to use this attribute among other things to give a dynamic non edit field. a none dynamic string from other attributes should use atkParserAttribute instead.
for example:
$this->add(new atkAttribute("first_name", AF_HIDE_LIST|AF_FORCE_LOAD));
$this->add(new atkAttribute("last_name", AF_HIDE_LIST|AF_FORCE_LOAD));
$this->add(new atkDummyAttribute("name_citation"));
function name_citation_display($record)
{
if (strlen($record["last_name"]) <> 0)
{
$string = $record["last_name"] . ", ". $record["first_name"];
}
else
{
$string = $record["first_name"];
}
return $string;
}
Note the AF_FORCE_LOAD without it the fields wont be in the returned result if AF_HIDE_LIST is used
from a table of:
| John | Doe |
| Jane |
This should produce:
Doe, John
Jane
FAQ
Where are the attribute labels?
The atkDummyAttribute defaults to no label. If you wish to reinstate the label, configure it as follows:
public static function meta(atkMetaPolicy $policy) {
$policy->add("additional_price", "atkDummyAttribute", array(null, AF_DUMMY_SHOW_LABEL));
}
(Do not attempt to set the flag using the third argument to add(), and do not attempt to remove the label afterwards; it must be passed through to the atkDummyAttribute constructor, as above.)
See Also
- Usage without DB I/O Polymorphism - prevent an attribute from attempting to access the database; useful if you want to create a dummy "structured" attribute, such as a date attribute