Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix cms fields etc for Fluent integration #8

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/EvoElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ public function inlineEditable(): bool
return $this->isInlineEditable();
}

public function beforeUpdateInlineCMSFields(callable $callback): void
{
$this->beforeExtending('updateInlineCMSFields', $callback);
}

public function afterUpdateInlineCMSFields(callable $callback): void
{
$this->afterExtending('updateInlineCMSFields', $callback);
}

/**
* No longer necessary/relevant
Expand Down
13 changes: 2 additions & 11 deletions src/Extensions/BaseElementExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ public function getInlineCMSFields(): FieldList
'CMSName',
'ParentID',
'ShowInMenusGroup',
'TopPageID',
]);

$htmlTextRows = (int) EditFormFactory::config()->get('html_field_rows');
Expand Down Expand Up @@ -901,7 +902,7 @@ public function getInlineCMSFields(): FieldList

$settingsTab = $fields->findOrMakeTab('Root.Settings');

if (!$this->isTitleEnabled()) {
if (!$this->getOwner()->isTitleEnabled()) {
$nameField = $this->getOwner()->getNameField();
$settingsTab->push($nameField);
}
Expand Down Expand Up @@ -946,16 +947,6 @@ public function getInlineCMSFields(): FieldList
return $fields;
}

public function beforeUpdateInlineCMSFields(callable $callback): void
{
$this->getOwner()->beforeExtending('updateInlineCMSFields', $callback);
}

public function afterUpdateInlineCMSFields(callable $callback): void
{
$this->getOwner()->afterExtending('updateInlineCMSFields', $callback);
}


/**
* Advanced Edit button/message for Inline/React form
Expand Down
22 changes: 14 additions & 8 deletions src/Model/ElementContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,24 @@ class ElementContent extends EvoBaseElement

public function getCMSFields(): FieldList
{
$this->beforeUpdateCMSFields(function($fields) {
$fields->addFieldToTab('Root.Main',
HTMLEditorField::create('Content', $this->fieldLabel('Content'))
);
});
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.ContentTabSet.Main',
HTMLEditorField::create('Content', $this->fieldLabel('Content'))
);
return $fields;
}

public function updateInlineCMSFields(FieldList $fields): void
public function getInlineCMSFields(): FieldList
{
$fields->addFieldToTab('Root.Main',
HTMLEditorField::create('Content', $this->fieldLabel('Content'))
->setRows(10)
);
$this->beforeUpdateInlineCMSFields(function($fields) {
$fields->addFieldToTab('Root.Main',
HTMLEditorField::create('Content', $this->fieldLabel('Content'))
->setRows(10)
);
});
$fields = parent::getInlineCMSFields();
return $fields;
}
}