Forms with groups and access levels
One field layout drives the form, the record view and saving: groups, collapsed groups and fields that are writable, read-only or hidden – also per record.
- A project that is done keeps its budget read-only.
- A manipulated POST cannot change a read-only field.
Try it: log in with the demo account
Email demo@frontdesk-demo.test · Password Try-Frontdesk-2026
Everyone shares this account. You may change anything – all data is reset every night.
The code
app/src/Controllers/ProjectController.php – defineFieldLayout()
whole file
/**
* Groups of the form and the view. A project that is done keeps its
* budget read-only; the feedback comes from the client and is read-only.
*/
protected function defineFieldLayout(?DataObject $record): ?FieldLayout
{
$layout = FieldLayout::create()
->group('Project', ['Title', 'ClientID', 'TypeID', 'Tags', 'Status', 'Priority'], true, 'basics')
->group('Schedule and budget', ['StartDate', 'EndDate', 'Budget', 'ManagerID'], true, 'schedule')
->group('Description', ['Description'], true, 'description')
->group('Internal', ['InternalNote'], false, 'internal')
->group('Client feedback', ['FeedbackRating', 'FeedbackText', 'FeedbackAt'], false, 'feedback')
->setLevels([
'FeedbackRating' => FieldLayout::READ,
'FeedbackText' => FieldLayout::READ,
'FeedbackAt' => FieldLayout::READ,
]);
if ($record?->Status === 'done') {
$layout->setLevel('Budget', FieldLayout::READ);
}
return $layout;
}