default value

Status
Not open for further replies.

lena

New Member
Hi,

I have to create a form for Book-DVD reservation.
For the shipping address I'm looking for the best way to do it.

Display User address by default-prefilled with CB profile address,
and add other address fields in case the shipping address is different.

or create a new profile for this resevation component
and next time this user want to make a resevation prefilled with these information and add the possibilities the edit the address?

Thanks
 
What version of Fabrik? I know I've probably asked this several times, but I'm dealing with so many support issues, I can't keep track of who is running what.

You can help by including your versions of Fabrik, J!, PHP and MySQL in your signature. This will get you answers quicker, as we don't have the extra delay while these basic questions are asked and answered.

-- hugh
 
shame on me

Hi,

Yes I agree with you.
I'm working on several projects, different servers, so I can't put these infos in my signature, but I will give you at least the Fabrik version :)

For this project this will be made using Fabrik 1.0.6.

Thanks
 
Unfortunately there is no built in way of doing this in F! 1.x.

There's several ways of achieving it, which one to use kind of depends on how you want the form to look and behave.

1) Do you always want to show the CB address as read-only data on the form, with "if different from above" fields to fill in if they need to?

2) Or do you just want to pre-fill the Fabrik address fields with the CB data as the default values when a new form is created?

Bear in mind that in 2), if you go back and edit the form, you won't see any of the default CB data, you'll only see what the form was last submitted with (default data is only filled in when a new form is created, not when a form is edited).

Either way there is some custom PHP to be written, either as the element default values and a form submit script, or as some additional PHP in the template.

We could also do this with some JavaScript/AJAX to dynamically grab the CB data whenever the form is loaded.

-- hugh
 
Do you want the read-only CB address to be submitted with the form, or does it just need to be displayed on the page?

-- hugh
 
OK. Can you bump this thread in a day or so. Rob and I are having a Mass Bug Squishing Session for 2.0, trying to stay focused on that for the moment.

-- hugh
 
OK, easiest way will be to use an eval'ed default, and grab the CB address data.

Create a set of elements equating to the CB address data you want. The defaults it installs with are address, city, state, zip, etc. Give 'em a prefix like cb_city, just to distinguish them from the editable set. Make the cb_ elements Read Only.

For the first one on the form (lets say it's cb_address), add this as the eval'ed default:

global $database, $my;
$database->setQuery("SELECT * FROM #__comprofiler WHERE user_id = '" . $my->id . '");
$cb_results = $database->loadObjectList();
return $cb_results->address;

Then for the subsequent ones (like cb_city), just use this:

return $cb_results->city;

If this throws notices/warnings, we may need to wrap some "if (!empty($cb_results)) {}" around the return values.

NOTE - if you have any additional fields which aren't in the main comprofiler table (all the defaults address ones are) you'll have to modify that query to join the required table(s).

-- hugh
 
Hi,

Hi have tried your code without success...empty field
Where exactly should I add ?:

global $database, $my;
$database->setQuery("SELECT * FROM #__comprofiler WHERE user_id = '" . $my->id . '");
$cb_results = $database->loadObjectList();
return $cb_results->adresse;


Thanks
 
little bit confused

Hi,

still not working I have made a test with other field same issue still empty.

I just want to make sure where I need to put this code:

global $database, $my;
$database->setQuery("SELECT * FROM jos_comprofiler WHERE user_id = '" . $my->id . '");
$cb_results = $database->loadObjectList();
return $cb_results['city'];

Element (field) in default value
and select Eval this text

or maybe the issue is a form setting or table setting or user access setting?

sorry I'm a little bit confused
 
Try putting this before the 'return' line:

echo $database->getErrorMsg();

... and see if it tells you anything.

-- hugh
 
Hi,

It's not returning any errors.

I really need to understand this cause I have 3 components to do using similar needs.
 
PM me backend login, and details about which form/element(s) I need to look at. Remember to include a link back to this thread in your PM.

-- hugh
 
Hi,

I'm doing tests on my PC locally.

Did you test the code you gave me?

global $database, $my;
$database->setQuery("SELECT * FROM #__comprofiler WHERE user_id = '" . $my->id . '");
$cb_results = $database->loadObjectList();
return $cb_results['address'];

What I need to setup to make this work I mean in form or table maybe the problem come from there.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top