Repository navigation
Prepare edit response on base Element class #10784
|
In Craft 4, sometimes it is desirable to prepare an element's edit page in the CP, for example:
I am currently dealing with this in my own public function prepEditResponse(Response|CpScreenResponseBehavior $response): void
{
Craft::$app->getView()->registerAssetBundle(...);
Craft::$app->getView()->getTwig()->addGlobal('selectedSubnavItem', '...');
$response->addAltAction(...);
$response->submitButtonLabel = '...';
}My WIP |
Replies: 1 comment 5 replies
|
We just released 4.0.0-beta.3 with a new
UPDATE The next release will also include the following changes (2329b5a):
|
We just released 4.0.0-beta.3 with a new
prepareEditScreen()method. It takes two arguments:yii\web\Response $response– The current response being prepared (which will have a CpScreenResponseBehavior attached to it)string $containerId– The ID that will be assigned to the element editor’s container elementUPDATE
The next release will also include the following changes (2329b5a):
CpScreenResponseBehavior::selectedSubnavItem()method, which can be called from elements’prepareEditScreen()methods.ElementInterface::getCrumbs(). Elements can set the crumbs viaCpScreenResponseBehavior::crumbs()fromprepareEditScreen()methods as well.