Field

Field data and information

Handling the value in certain field of certain row.

Kenttä -object can be referred through Page -objects property or method that returns field(s).

Use examples

Value change

Show feedback, if 'Status' -field value is changed to value 'New'.

if ( $Order->status->isChanged() && $Order->status->oldValue() == 'New' ){
    $this->get("notification","Status is changed from New to {$Order->status->getValue()}");
}

Calculating with field value

Field has a Field::getNumber() -method, that returns the countable presentation of value in field. For example duration Duration -fields value 01:15 is 1.25 as countable number.

Calculate total from work hours and employees hour rate:

$total = $Workhour->hours->getNumber() * $Workhour->employee->hour_rate->getNumber();

Page::calculate() -method uses the Field::getNumber() values. Example above can also be written:

$total = $Workhour->calculate('hours * employee.hour_rate');

Fieldtype methods and attributes

Osalla kentistä on omia kenttätyyppikohtaisia metodeita kentän tietojen käsittelyyn.

Tiedosto -kentän 240x240 esikatselukuvan näyttäminen:

$txt .= "<img src='{$Product->product_image->thumb}&s=240'/>";

Liitos -sivun tiedon näyttäminen; projektin asiakkaan nimi:

$name = $Order->client->getPage()->name;

Jos liitos -kentältä pyydetään atribuuttia, palautetaan kohdesivun atribuutti eli liitetyn sivun pyydetyn kentän Kentta -olio. Edellisen voi siis kirjoittaa myös:

$name = $Order->client->namne;

Vitte -field can refer to all pages that are linked to this page. Loop through multiple pages: Show all orders where this client is customer:

foreach ( $Client->order__customer->getPages() as $Order ){
    $txt .= "<p>{$Order->order_number} {$Order->delivery_date}</p>";
}

Methods