AnswerBun.com

Admin grid save & continue edit button - ui components

Magento Asked by Rihards Repels on January 6, 2022

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">VendorProductCommentsBlockAdminhtmlCommentEditBackButton</item>
        <item name="saveAndContinueEdit" xsi:type="string">VendorProductCommentsBlockAdminhtmlCommentEditSaveAndContinueButton</item>
        <item name="save" xsi:type="string">VendorProductCommentsBlockAdminhtmlCommentEditSaveButton</item>
        <item name="delete" xsi:type="string">VendorProductCommentsBlockAdminhtmlCommentEditDeleteButton</item>
    </item>

SaveAndContinueButton.php:

<?php

namespace VendorProductCommentsBlockAdminhtmlCommentEdit;

use MagentoFrameworkViewElementUiComponentControlButtonProviderInterface;

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?

One Answer

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">vendorProductCommentsBlockAdminhtmlIndexEditButtonBack</item>
            <item name="delete" xsi:type="string">vendorProductCommentsBlockAdminhtmlIndexEditButtonDelete</item>
            <item name="reset" xsi:type="string">vendorProductCommentsBlockAdminhtmlIndexEditButtonReset</item>
            <item name="save" xsi:type="string">vendorProductCommentsBlockAdminhtmlIndexEditButtonSave</item>
            <item name="save_and_continue" xsi:type="string">vendorProductCommentsBlockAdminhtmlIndexEditButtonSaveAndContinue</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.

Answered by Tushar on January 6, 2022

Add your own answers!

Related Questions

Send email to a friend is not working

2  Asked on December 26, 2020 by bineesh

     

How in Block a productcollection of template render?

2  Asked on December 24, 2020 by andrej-wasemiller

     

Magento 2 Sort order on catalogue widget

0  Asked on December 23, 2020 by carter

   

MAC OS Magento 2.4.1. PWA Studio 8.0.0 Local Setup Steps and Bugfix

0  Asked on December 19, 2020 by rishimukesh

   

Overriding Helper

2  Asked on December 19, 2020 by myron

   

Magento emails are not going

1  Asked on December 18, 2020 by user00247

   

Problem with payment,

1  Asked on December 16, 2020 by mariam-todadze

     

Special Price Not Applying in Magento2 Cart

2  Asked on December 14, 2020 by dinesh

       

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP