Hello,
I am creating an edit form where I need to pre-fill some of the fields using values from database. Loading desired form fields work nicely when I refer to just one table e.g., with my table definition in component`s src/Tables/CustomersTable.php
I can do $this->getItem() inside loadFormData() in a model what in turn makes all the fields available in a form.
The problem I am trying to solve is how to pre-fill my form using data from two tables. For example instead showing just an id of a product that customer has bought I would like to show the full name of the product but that full name is in another table.
Any hints welcome, thanks!
I am creating an edit form where I need to pre-fill some of the fields using values from database. Loading desired form fields work nicely when I refer to just one table e.g., with my table definition in component`s src/Tables/CustomersTable.php
Code:
class CustomerTable extends Table{/** * Constructor * * @param DatabaseDriver $db Database connector object * * @since 1.0 */public function __construct(DatabaseDriver $db){parent::__construct('#__customers', 'id', $db);}}
I can do $this->getItem() inside loadFormData() in a model what in turn makes all the fields available in a form.
The problem I am trying to solve is how to pre-fill my form using data from two tables. For example instead showing just an id of a product that customer has bought I would like to show the full name of the product but that full name is in another table.
Any hints welcome, thanks!
Statistics: Posted by JanoD — Wed Jul 31, 2024 2:51 pm