Hi,
I'm guessing this is one of those questions the answer is very simple, but I've already lost a lot of hours over this, and am ready to start trying workarounds I really would prefer not to ...
So, I'me putting some php code in a form plug-ins in the "hook" OnBeforeProcess.
I had no problem with the this first part
//------------------------------------------------------------------------------------------------
$foo = $formModel->getElementData('jo_marc___equip_type', false);
$type_equip = is_array($foo) ? $foo[0] : $foo;
$foo = $formModel->getElementData('jo_marc___client_id',false);
$client = is_array($foo) ? $foo[0] : $foo;
$label = $type_equip. "-". $client;
$formModel->updateFormData('jo_marc___Label', $label , true);
When I submited the form it created my table record, with the value of the updated element no problem.
when I added this part(bellow), after submit, although it does not report any error, it also don't insert any new record in the database table... any ideas?
//------------------------------------------------------------------------------------------------
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('name', 'address', 'location', 'cell', 'comment'))
->from('jo_clients')
->where('cli_id = ' . $client);
$myDb->setQuery($myQuery);
$row = $myDb->LoadObject();
//$formModel->updateFormData('jo_marc___client_name', $row->name,true);
//$formModel->updateFormData('jo_marc___client_address', $row->address, true);
//$formModel->updateFormData('jo_marc___client_location', $row->location, true);
//$formModel->updateFormData('jo_marc___client_cell',$row->cell, true);
//$formModel->updateFormData('jo_marc___client_comment', $row->comment, true);
thanks!
I'm guessing this is one of those questions the answer is very simple, but I've already lost a lot of hours over this, and am ready to start trying workarounds I really would prefer not to ...
So, I'me putting some php code in a form plug-ins in the "hook" OnBeforeProcess.
I had no problem with the this first part
//------------------------------------------------------------------------------------------------
$foo = $formModel->getElementData('jo_marc___equip_type', false);
$type_equip = is_array($foo) ? $foo[0] : $foo;
$foo = $formModel->getElementData('jo_marc___client_id',false);
$client = is_array($foo) ? $foo[0] : $foo;
$label = $type_equip. "-". $client;
$formModel->updateFormData('jo_marc___Label', $label , true);
When I submited the form it created my table record, with the value of the updated element no problem.
when I added this part(bellow), after submit, although it does not report any error, it also don't insert any new record in the database table... any ideas?
//------------------------------------------------------------------------------------------------
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('name', 'address', 'location', 'cell', 'comment'))
->from('jo_clients')
->where('cli_id = ' . $client);
$myDb->setQuery($myQuery);
$row = $myDb->LoadObject();
//$formModel->updateFormData('jo_marc___client_name', $row->name,true);
//$formModel->updateFormData('jo_marc___client_address', $row->address, true);
//$formModel->updateFormData('jo_marc___client_location', $row->location, true);
//$formModel->updateFormData('jo_marc___client_cell',$row->cell, true);
//$formModel->updateFormData('jo_marc___client_comment', $row->comment, true);
thanks!