Skip to content

How to use Controller::asCpScreen() #13193

Answered by AugustMiller
mikejpeters asked this question in Q&A
Discussion options

You must be logged in to vote

You're definitely on the right track, here! Yes, asCpScreen() is the preferred method for generating responses that target multiple contexts.

This section of the element type docs covers our recommendations for handling the edit view for your element.

In short, letting Craft construct the view via the elements/edit controller action will provide virtually everything an element relies on.

Beyond that, you can implement the metadata(), metaFieldsHtml(), and prepareEditScreen() methods to customize the screen and its output—without having to maintain your own controller action.

The two meta* methods here are likely what you're looking for with respect to altering the contents of the sidebar. ✌️

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mikejpeters
Comment options

Answer selected by mikejpeters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants