Skip to content

Apply provisional drafts in a custom controller #15272

Closed Answered by brandonkelly
shifuma asked this question in Q&A
Discussion options

You must be logged in to vote

I’d just go about this by adding a formsubmit class to the button, which gives you an opportunity to register a new param value on the form, but otherwise let is submit the form normally.

use craft\base\Element;
use craft\base\Event;
use craft\elements\Entry;
use craft\events\DefineHtmlEvent;
use craft\helpers\Html;

Event::on(Entry::class, Element::EVENT_DEFINE_SIDEBAR_HTML, function(DefineHtmlEvent $event) {
    $event->html .= Html::button('Run action', [
        'class' => ['btn', 'submit', 'formsubmit'],
        'data' => [
            'param' => 'copyValue',
            'value' => '1',
        ],
    ]);
});

With that in place, you could then register an after-save listener that che…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@shifuma
Comment options

@shifuma
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
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