0

I want to set "Add New" button path in custom Blog file.Please Help me out in this.

class Post extends \Magento\Backend\Block\Widget\Grid\Container
{

    protected function _construct()
    {
        $this->_controller = 'adminhtml_post';
        $this->_blockGroup = 'blockgroupnamew';
        $this->_headerText = __('Posts');
        $this->_addButtonLabel = __('Create New post');


        parent::_construct();
    }
}
0

Try to include this function in your current 'post' class

protected function _prepareLayout() {
         $addButtonProps = [
            'id' => 'gridGrid',
            'label' => __('Add New'),
            'class' => 'add',
            'button_class' => '',
            'onclick' => "setLocation('" . $this->_getCreateUrl() . "')",
            'style' => "background-color: #eb5202;border-color: #eb5202;color: #fff;"
        ];
        $this->buttonList->add('add_new', $addButtonProps);

        return parent::_prepareLayout();
    }

protected function _getCreateUrl() {
    return $this->getUrl(
                    '*/*/newaction'
    );
}

Your Answer

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