I am developing a mvc component for both joomla 2.5 and 3.In many components i saw they added joomla's default command buttons like new, edit, publish, trash, options at top of their settings page in admin side. Eg. if one goes components->weblinks->links page, i am talking about those command buttons at top right.

So how do i add those command buttons in my component's settings page? when clicked it would do respective action and show respective view.For instance, if i click "new" button it will display my mvc component's add entry view as it is.

So how could i add fully workable joomla's command buttons in my component's settings page in admin side.

2 Answers 2


The best practice is to create the addToolBar() method inside your View class and then using JToolBarHelper class to create command buttons:

protected function addToolBar()

So these will call the task/function "add"/"edit" in your specified controller. Then simply call $this->addToolBar() in your View's display() method.

Reference Creating a toolbar for your component

  • I have only a controller file controller.php in my component and inside it i have a function function add() { JRequest::setVar('view', 'entry'); JRequest::setVar('layout', 'form'); parent::display(); } so in my view.html.php file i added JToolBarHelper::addNewX('controller.add'); then new button appears but when clicked it does not go to my view form instead adds a # to the url
    – dev-m
    Commented Apr 27, 2014 at 20:12
  • Try to omit controller.task - JToolBarHelper::addNewX(); Commented Apr 28, 2014 at 7:51
  • Added only JToolBarHelper::addNewX(); but not works.
    – dev-m
    Commented Apr 28, 2014 at 12:52
  • Then you need to create a proper controller under controllers directory. See Adding backend actions Commented Apr 28, 2014 at 17:14

You need to make sure the view that displays the buttons has a form to submit. The form name should be adminForm. The form should also have a hidden field named task and the dynamically generated token. I cannot recall the API off the top of my head, but something like JHtml::_('form.token'); (someone please correct this, if I'm mistaken)

This do the trick.

  • The problem i found out before was that i was using form name as adminform instead adminForm.it seems joomla kind of case sensitive!
    – dev-m
    Commented May 8, 2014 at 20:33
  • It's more of a JavaScript thing than Joomla specific. When you click the buttons you are actually triggering a JS submit form function, so if the form can't be found then it quietly fails. Commented May 8, 2014 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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