Ecovoyageurs
Member
Hi again,
On my quotations requests form (quotations_requests table), I use the upsert plugin to create a new customer (customers table) if the customer isn't known (if his email isn't in the customers table yet).
Now, in the same form, I'd like to grab the customer id and update my quotation requests field (dbjoin) to create a relation between the 2 tables.
I don't know when the upsert query is run, but is it possible (during the form validation process) to :
1 - run the upsert query
2 - get the customer id and update the form customer_id field
Currently I created 2 plugins for my form:
- the upsert plugin and it works great as defined above (set as 1st plugin on my form)
- the PHP plugin with the following code
The query seems to run (no error), but the client_id field isn't filled... that's why I wonder if it's possible to run a PHP query after the upsert plugin.
Thanks for any help !
On my quotations requests form (quotations_requests table), I use the upsert plugin to create a new customer (customers table) if the customer isn't known (if his email isn't in the customers table yet).
Now, in the same form, I'd like to grab the customer id and update my quotation requests field (dbjoin) to create a relation between the 2 tables.
I don't know when the upsert query is run, but is it possible (during the form validation process) to :
1 - run the upsert query
2 - get the customer id and update the form customer_id field
Currently I created 2 plugins for my form:
- the upsert plugin and it works great as defined above (set as 1st plugin on my form)
- the PHP plugin with the following code
PHP:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$email = "{quotations_requests___email}";
$query->clear();
$sql = 'SELECT id FROM customers WHERE email = "' . $email . '"';
$db->setQuery($sql);
$client_id = $db->loadResult();
$formModel->updateFormData('quotations_requests', $client_id);
The query seems to run (no error), but the client_id field isn't filled... that's why I wonder if it's possible to run a PHP query after the upsert plugin.
Thanks for any help !