From 88d3076b9d014c4ce61094c01d143247680e156a Mon Sep 17 00:00:00 2001 From: Tony Air Date: Fri, 8 Apr 2022 11:12:47 +0200 Subject: [PATCH] IMPR: Better Submitted Forms titles --- _config/base-extensions.yml | 4 ++++ src/Extensions/SubmittedFormEx.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/Extensions/SubmittedFormEx.php diff --git a/_config/base-extensions.yml b/_config/base-extensions.yml index db541e4..7071642 100755 --- a/_config/base-extensions.yml +++ b/_config/base-extensions.yml @@ -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 diff --git a/src/Extensions/SubmittedFormEx.php b/src/Extensions/SubmittedFormEx.php new file mode 100644 index 0000000..4e56d7b --- /dev/null +++ b/src/Extensions/SubmittedFormEx.php @@ -0,0 +1,28 @@ +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; + } +} \ No newline at end of file