After a long learning curve I am posting this here so that should I need it again in the future or if others need it, it is here for reference.
Project: I needed to load logged in Community Builder users information into a BreezingForm. This included their name, email, complete address and phone. Here is what I did:
- First I setup the piece that inserts the Community Builder values into the form:
- BreezingForms > Manage Pieces > New
- Title: CB_values
- Published: Yes
- Package: CB Integration
- Name: ff_load_CB_values
- Type: Before Form
- Description: This code inserts the CB user information into the BF form.
- Code:
Code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$user = &JFactory::getUser();//Get user Object
//Create your own query
$db->setQuery('Select * From #__comprofiler Where id='.$user->id);
$results = $db->loadObject(); //load the results from the query
// populate the values in the form
ff_setValue('name', $results->firstname." ".$results->lastname);
ff_setValue('email', $user->email);
ff_setValue('phone', $results->cb_phone);
ff_setValue('address', $results->cb_address);
ff_setValue('city', $results->cb_city);
ff_setValue('postcode', $results->cb_zipcode);
ff_setValue('country', $results->cb_country);
- Save
- I created a form that had, in addition to form specific elements, the following elements with the following - Labels : Names (note the only important part is the names as these connect with the code above. Both may be substituted for your own needs however.)
- Name : name
- Email : email
- Address : address
- City : city
- Province : province
- Postal Code : postcode
- Country : country
- Phone : phone
- Next I updated the form to include the integration piece:
- Advanced Tab > Form Options > More options
- Form Pieces > Before Form > Library
- select - CB Integration::ff_load_CB_values
- Save
Now when you are logged in and go to your form, the information from your CB profile will be pre-loaded into the form.
I hope this saves others a bit of time.