0

So as you already understand I want to create Save & Continue Edit button with ui components. Here is my ui components file:

 <item name="buttons" xsi:type="array">
 <item name="back" xsi:type="string">Vendor\ProductComments\Block\Adminhtml\Comment\Edit\BackButton</item>
 <item name="saveAndContinueEdit" xsi:type="string">Vendor\ProductComments\Block\Adminhtml\Comment\Edit\SaveAndContinueButton</item>
 <item name="save" xsi:type="string">Vendor\ProductComments\Block\Adminhtml\Comment\Edit\SaveButton</item>
 <item name="delete" xsi:type="string">Vendor\ProductComments\Block\Adminhtml\Comment\Edit\DeleteButton</item>
 </item>

SaveAndContinueButton.php:

<?php
namespace Vendor\ProductComments\Block\Adminhtml\Comment\Edit;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
{
 /**
 * @return array
 */
 public function getButtonData()
 {
 return [
 'label' => __('Save and Continue Edit'),
 'class' => 'save',
 'data_attribute' => [
 'mage-init' => ['button' => ['event' => 'save']],
 'form-role' => 'save',
 ],
 'sort_order' => 80,
 ];
 }
}

My save button is working correctly, but when I press save and continue button, it just goes to admin index page. Also I haven't yet decided how to do that so it stays on edit page, but first I need to fix it so it uses Save.php controller. For save button i did this:

<item name="config" xsi:type="array">
 <item name="submit_url" xsi:type="url" path="*/*/save"/>
 </item>

Do i need to do something like this also for save and continue button?

asked Jan 30, 2018 at 13:11

1 Answer 1

1

First you can use this block use in our UI components xml Files.

<item name="buttons" xsi:type="array">
 <item name="back" xsi:type="string">vendor\ProductComments\Block\Adminhtml\Index\Edit\Button\Back</item>
 <item name="delete" xsi:type="string">vendor\ProductComments\Block\Adminhtml\Index\Edit\Button\Delete</item>
 <item name="reset" xsi:type="string">vendor\ProductComments\Block\Adminhtml\Index\Edit\Button\Reset</item>
 <item name="save" xsi:type="string">vendor\ProductComments\Block\Adminhtml\Index\Edit\Button\Save</item>
 <item name="save_and_continue" xsi:type="string">vendor\ProductComments\Block\Adminhtml\Index\Edit\Button\SaveAndContinue</item>
</item>

Then you can open save and continue block open and can you use this code

public function getButtonData() {
 return [
 'label' => __('Save and Continue Edit'),
 'class' => 'save',
 'data_attribute' => [
 'mage-init' => [
 'button' => ['event' => 'saveAndContinueEdit'],
 ],
 ],
 'sort_order' => 80,
 ];

We also faced this issue, This code working you can use it.

Abhishek Tripathi
2,9152 gold badges21 silver badges38 bronze badges
answered Mar 31, 2018 at 7:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.