Skip to content

Commit

Permalink
NEW Add NonInlineEditableExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 30, 2024
1 parent 3791f91 commit d690b4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/elemental/ElementContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\FrameworkTest\Elemental\Extension;

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\ValidationResult;
Expand All @@ -20,6 +21,10 @@ class ElementContentExtension extends Extension
'MyInt' => 'Int',
];

private static $has_one = [
'MyPage' => SiteTree::class,
];

public function validate(ValidationResult $result)
{
if ($this->owner->Title == 'x') {
Expand All @@ -35,7 +40,7 @@ public function validate(ValidationResult $result)

public function updateCMSCompositeValidator(CompositeValidator $compositeValidator)
{
$compositeValidator->addValidator(new RequiredFields(['Title']));
$compositeValidator->addValidator(new RequiredFields(['Title', 'MyPage']));
}

public function updateCMSFields(FieldList $fields)
Expand Down
10 changes: 10 additions & 0 deletions code/elemental/NonInlineEditableExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace SilverStripe\FrameworkTest\Elemental\Extension;

use SilverStripe\Core\Extension;

class NonInlineEditableExtension extends Extension
{
private static $inline_editable = false;
}

0 comments on commit d690b4c

Please sign in to comment.