• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[SOLVED]Form PHP plugin - End of form submission (onAfterProcess) - Update database fields

marcq

Member
Hi,

I have created a form which enables people to submit an Inquiry.

After submit, data?s are stored in the ?pbdf_fabrik_user_demande_conseils? database table :

?pbdf_fabrik_user_demande_conseils? table fields :
id
date_record
statut
degreurgence
userid (userid of the registered user which is submitting the form)
no_assure
username
name
firstname
usergroup
titre
demande
typedemande
piecesjointes
titre_demcons_client

The ?no_assure?, ?name? and ?firstname? fields are empty and should be retrieved from the ?pbdf_fabrik_user_clients? database table and populate this 3 empty fields with the data that belong to the registred user which is submitting the form :

?pbdf_fabrik_user_clients? table fields :
id
date_record
date_update
last_visite
user_group
userid
username
name
firstname
email
password
no_assure

Question :
Can I use the Form PHP plugin, End of form submission (onAfterProcess), to update the 3 fields of the record which just have been created in the ?pbdf_fabrik_user_demande_conseils? table with the values of the ?pbdf_fabrik_user_clients? table ? Is it the right way to do ?
If yes, could someone kindly explain me how the build my query in order to retrieve those data?s and update the 3 mentioned fields with the values that belong to the registered user which is submitting the form ? I?m a very newby which have less experience in building sql queries so I would appreciate if someone could explain me how to solve this issue.

Thanks in advance!

Cheers,

Marc


Fabrik version 3.2
Joomla 3.3.6
 
Hi troester,

Thanks for your reply. I used the autofill plugin which work well. Data's are displayed accordingly in the 3 form fields ?no_assure?, ?name? and ?firstname?. But when I submit the form, database fields are empty.

Could you please check my parameter in the autofill plugin please (see attached), perhaps I've made a mistake.

Thanks in advance,

Marc
 

Attachments

  • AUTOFILL.pdf
    94.4 KB · Views: 323
Friendly bump

As told before Data's are displayed correctely now.

Since the autofill related data's are not saved in the database on form submit I would appreciate if someone could advise me how to solve this issue.

Thanks in advance,

Marc
 
PHP Form Plugin - My solution which is certainly not elegant at all, but works like a charm for those who might be interested :

$db = JFactory::getDbo();
// Get the record ID of the submitted form
$id=$data['pbdf_fabrik_user_soumission_ordonnance___id_raw'];
// Get the Userid of the User which submitted the form
$userid={$my->id};

// Get the autofill fields related data
$queryname = $db->getQuery(true);
$queryname->select('name')->from('pbdf_fabrik_user_clients')->where('userid = ' . (int) '{pbdf_fabrik_user_soumission_ordonnance___userid_raw}');
$db->setQuery($queryname);
$name = $db->loadResult();

$queryfirstname = $db->getQuery(true);
$queryfirstname->select('firstname')->from('pbdf_fabrik_user_clients')->where('userid = ' . (int) '{pbdf_fabrik_user_soumission_ordonnance___userid_raw}');
$db->setQuery($queryfirstname);
$firstname = $db->loadResult();

$queryno_assure = $db->getQuery(true);
$queryno_assure->select('no_assure')->from('pbdf_fabrik_user_clients')->where('userid = ' . (int) '{pbdf_fabrik_user_soumission_ordonnance___userid_raw}');
$db->setQuery($queryno_assure);
$no_assure = $db->loadResult();

// Update query
$query = $db->getQuery(true);
$query= "UPDATE pbdf_fabrik_user_soumission_ordonnance SET pbdf_fabrik_user_soumission_ordonnance.name = '$name', pbdf_fabrik_user_soumission_ordonnance.firstname = '$firstname', pbdf_fabrik_user_soumission_ordonnance.no_assure = '$no_assure' WHERE pbdf_fabrik_user_soumission_ordonnance.id = '$id' ";
$db->setQuery($query);
$db->execute();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top