TransWikia.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!

Ask a Question

Get help from others!

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