Let me add for clarity that I am using Mywalks demo component as my baseline. My model looks as follows. I assume calling $this->getItem() inside loadFormData() gets a row from a table defined in the very first post. The problem is that a row I want to get must be combined using two (or possibly several) tables.
Do I need to abandon using Table() and overload getItem() method in my model with an SQL query that does a join of two tables and fetches a desired row?
Do I need to abandon using Table() and overload getItem() method in my model with an SQL query that does a join of two tables and fetches a desired row?
Code:
class CustomerModel extends AdminModel {.../** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return Table A Table object * * @since 3.0 * @throws \Exception */public function getTable($name = '', $prefix = '', $options = array()){$name = 'customers';$prefix = 'Table';if ($table = $this->_createTable($name, $prefix, $options)){return $table;}throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name), 0);}/** * Method to get the record form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */public function getForm($data = array(), $loadData = true){// Get the form.$form = $this->loadForm('com_customers.customer', 'customer', array('control' => 'jform', 'load_data' => $loadData));if (empty($form)){return false;}return $form;}/** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * * @since 1.6 */protected function loadFormData(){// Check the session for previously entered form data.$app = Factory::getApplication();$data = $app->getUserState('com_customers.edit.customer.data', array());if (empty($data)){$data = $this->getItem();// Pre-select some filters (Status, Category, Language, Access) in edit form if those have been selected in Article Manager: Articles}$this->preprocessData('com_customers.customer', $data);return $data;}
Statistics: Posted by JanoD — Thu Aug 01, 2024 8:53 am