Jump to content

hookDisplayAdminProductsExtra


Rodrigo B Laurindo

Recommended Posts

I am trying to add a new tab in products edit page in back office using hook DisplayAdminProductsExtra:

public function hookDisplayAdminProductsExtra($params) {
    if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product'))))
    {
       return $this->renderAdminProductsExtraTab($product);
    }
}

And

  function renderAdminProductsExtraTab($product = 0)
  {   
		$fields_form_1 = array(
			'form' => array(
				'legend' => array(
					'title' => $this->l('Regras do Visual Correios para frete'),
					'icon' => 'icon-cogs'
				),
				'input' => array(
					array(
						'label' => $this->l('My field'),
						'type' => 'text',
						'name' => 'myfield',
					),
				),
			'submit' => array(
				'title' => $this->l('Save'),
				'class' => 'btn btn-default pull-right',
				'name' => 'submitEditExtraTab',
				)
 			),
		);

		$helper = new HelperForm();
		$helper->show_toolbar = false;
                $helper->table =  $this->name;
		$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
		$helper->default_form_language = $lang->id;
		$helper->module = $this;
		$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
		$helper->identifier = $this->identifier;
		$helper->submit_action = 'submitEditExtraTab';
		$helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
		$helper->token = Tools::getAdminTokenLite('AdminProducts');
	        $helper->toolbar_btn = array(
                    'save' =>
                         array(
                               'short' => 'Save',
                               'desc' => $this->l('Save'),
                               'href' => AdminController::$currentIndex,
                        ),
                );	
		$helper->tpl_vars = array(
			'fields_value' => $this->getExtraTabFieldsValues($product->id),
			'languages' => $this->context->controller->getLanguages(),
			'id_language' => $this->context->language->id
		);

		return $helper->generateForm(array($fields_form_1));
  }

This code works, but it shows only a Save button. How can I get "Cancel" and "Save and stay" buttons as in other product tabs?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...