2

I'm developing a component. At admin at the list of item, I get this error when I click on the + New button:

[Error] Error: The form "adminForm" is required to perform the task, but the form was not found on the page.

connectedCallback (joomla-toolbar-button.js:62:128)
define
Modulcode (joomla-toolbar-button.js:5)

In the controller $ADMIN/src/Events/HTMLView.php in addToolbar() I have e.g. this code:

if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_eventcalendar', 'core.create')) > 0) {
            $toolbar->addNew('events.add');
}

What denotes the events in the 'events.add' string?

The above mentioned error appears, but nothing else happens.

Models in $ADMIN/src/Model:

class EventsModel extends AdminModel {}
class EventModel extends AdminModel {}

1 Answer 1

1

What denotes the events in the 'events.add' string?

The 'events.add' is the the same as specifying &task=events.add in the URL of a link, both of which will direct processing to a Controller called EventsController and the function/method within that Controller called add within the current component.

e.g.

class EventsController extends ...
{
   public function add()
   {
      ...
   }
}

In your example here the New button does not use any information from the List page but it still expects there to be a <form> defined called adminForm as most button/link actions is essentially triggering the form to be Submitted, or processed, using Joomla.submit(). I had a similar issue when learning and it was explained here that the name of the form needs to adminForm for the default joomla.submit() to work or pass it a different name. TypeError: Form is Null on Button in Admin toolbar

The obvious example for using the values set in a '<form>' is if you have used the default checkbox approach for your list table. Once you select one or more checkbox's and chose a Menu item like Publish/Unpublish the values of the checkbox's and any other inputs of the form are available to the Controller that is called, in your case EventsController, by getting the right property from the Input object via a statement like this in your controller;

$ids        = (array)$this->input->get('cid', array(), 'int') 

cid is the array that holds the values, usually a record identifier of some sort, for each box that was checked on the list.

In the tmpl file for your List page you would probably use this core function to display and handle the show/noshow of the box being checked.

<td class="text-center">
    <?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>

Another use case is the Search & Filter bar that is displayed on many List pages are are <input>'s and therefore expected to be within a <form> element.

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.