AtkDummyAttribute: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
for example: | for example: | ||
<syntaxhighlight lang="php"> | |||
$this->add(new atkAttribute("first_name", AF_HIDE_LIST|AF_FORCE_LOAD)); | $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 atkAttribute("last_name", AF_HIDE_LIST|AF_FORCE_LOAD)); | ||
$this->add(new atkDummyAttribute("name_citation")); | $this->add(new atkDummyAttribute("name_citation")); | ||
function name_citation_display($record) { | function name_citation_display($record) | ||
if (strlen($record["last_name"]) <> 0) { | { | ||
if (strlen($record["last_name"]) <> 0) | |||
{ | |||
$string = $record["last_name"] . ", ". $record["first_name"]; | $string = $record["last_name"] . ", ". $record["first_name"]; | ||
} else { | } | ||
else | |||
{ | |||
$string = $record["first_name"]; | $string = $record["first_name"]; | ||
} | } | ||
| Line 16: | Line 21: | ||
return $string; | return $string; | ||
} | } | ||
</syntaxhighlight> | |||
Note the AF_FORCE_LOAD without it the fields wont be in the returned result if AF_HIDE_LIST is used | Note the AF_FORCE_LOAD without it the fields wont be in the returned result if AF_HIDE_LIST is used | ||
Revision as of 21:27, 17 December 2007
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