IMPR: Better Submitted Forms titles

This commit is contained in:
Tony Air 2022-04-08 11:12:47 +02:00
parent 70ed43839a
commit 88d3076b9d
2 changed files with 32 additions and 0 deletions

View File

@ -40,6 +40,10 @@ SilverStripe\UserForms\Form\UserForm:
extensions:
- A2nt\CMSNiceties\Extensions\PlaceholderFormExtension
SilverStripe\UserForms\Model\Submission\SubmittedForm:
extensions:
- A2nt\CMSNiceties\Extensions\SubmittedFormEx
Page:
searchable_objects:
- A2nt\CMSNiceties\Models\TeamMember

View File

@ -0,0 +1,28 @@
<?php
namespace A2nt\CMSNiceties\Extensions;
use SilverStripe\ORM\DataExtension;
class SubmittedFormEx extends DataExtension
{
public function Title()
{
$obj = $this->owner;
$parent = $obj->Parent();
$title = '#' . $obj->ID;
if(!$parent) {
return $title;
}
$cols = $parent->SubmissionColumns();
foreach ($cols as $col) {
$name = $col->getField('Name');
$title .= ' '.$item->relField($name);
}
return $title;
}
}