2

I have created admin grid and form using ui component.
Now I need to add save and continue button, How do I add it?
Please provide me a solution

2

Add below code to UI component form XML file

<item name="buttons" xsi:type="array">
    <item name="save_and_continue" xsi:type="string">Namespace\ModuleName\Block\Adminhtml\ModuleName\Edit\SaveAndContinueButton</item>
</item>

 

<?php

namespace Namespace\ModuleName\Block\Adminhtml\ModuleName\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

/**
 * Class SaveAndContinueButton
 */
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' => 'saveAndContinueEdit'],
                ],
            ],
            'sort_order' => 80,
        ];
    }
}
  • Am I need to add controller for this? – Jaisa Feb 8 '18 at 6:43
  • Yes you need to create a save action controller, it should be define in submit _url in form.xml file. – Suresh Chikani Feb 8 '18 at 6:46
  • I have already created save controller for save button , Now additionally am I neeed to create saveandcontinue controller?? – Jaisa Feb 8 '18 at 6:48
  • No, You don't need to create additionally. – Suresh Chikani Feb 8 '18 at 6:49
  • But while clicking save and continue button its hows 404 error – Jaisa Feb 8 '18 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.