Sat 27 Sep |
|
Just for my own info - how a delete works from the Joomla Admin I have a component with a view "records"You would have a JS delete button in your view which points to "records.delete" formed in your html.php file protected function addToolbar() . //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'records.delete','JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('records.trash','JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } Clicking this calls the controller "records" and could run the function delete() if configured. If not configured in the "records" controller it extends JControllerAdmin which is found in "libraries/legacy/controller/admin.php". This function delete() makes some security checks and then loads the model (GporganiserModelRecord Object) using the getModel function and runs the delete function there if one is configured. This loads the model for a single "record", not the" records" model. If no delete is configured in models/record this model then extends "JModelAdmin" in libraries/legacy/model/admin.php which again has the "delete" function. This model (JModelAdmin) delete() again makes some security checks and triggers some plugin events then runs the delete function of the libraries/joomla/table/table.php. This function is found in JTable itself and will run a simple delete query. Be careful because in the delete functio it call the bind() in the same JTable class. If for example you have a bind() in administrator/components/com_gporganiser/tables/record.php this will take precedence! In this case I had public function bind($array, $ignore = '') { $input = JFactory::getApplication()->input; $task = $input->getString('task', ''); if($task != 'save' ) { return parent::bind($array, $ignore); //hand back to the JTable bind() } } |
Last Updated on Saturday, 27 September 2014 19:04 |