class MyTable extends DataObject { public static $fieldLabels = array( 'FieldNameOne' => 'Custom Label One', 'FieldNameTwo' => 'Custom Label Two', 'FieldNameThree' => 'Custom Label Three', ); }
$fields = MyTable::get()->first()->db(); foreach ($fields as $fieldName => $fieldValue) { $label = MyTable::fieldLabel($fieldName); // Output the label and field value to the template echo "In this example, we are accessing the field labels for the fields in the MyTable database table and outputting them to a template. Package Library: Silverstripe ORM (Object-relational mapping)$label: $fieldValue
"; }