Dear Bob,
me again.
After having a lot of fun generating easy forms I come up again with a question:
I like to add a picture in a form.
The path including the file name is in a field of a record.
I load in the action the record and show the html.
between the fields of the form I add on the place for the picture a user action with only code.
There I add if (!empty($form->data['xy'])) {.....}
I check in the db that the field has a value '/bla/bla/bla/pic.jpg'
But every time the code is not called.
Trying print_r($form->data['xy']) brings an empty value.
How can I access the record value?
Best regards
Thomas
me again.
After having a lot of fun generating easy forms I come up again with a question:
I like to add a picture in a form.
The path including the file name is in a field of a record.
I load in the action the record and show the html.
between the fields of the form I add on the place for the picture a user action with only code.
There I add if (!empty($form->data['xy'])) {.....}
I check in the db that the field has a value '/bla/bla/bla/pic.jpg'
But every time the code is not called.
Trying print_r($form->data['xy']) brings an empty value.
How can I access the record value?
Best regards
Thomas
Hi Thomas,
How are you getting the data from the database? With a DB Record Loader action? Please add a Debugger action to the On Load event and copy and paste the output here.
You will also need a URL for the image to display it in your form, not a path so you'll need to use a Custom Code action to convert from one to the other. Here the key part of the code to do that from the Upload File [GH] action
Bob
How are you getting the data from the database? With a DB Record Loader action? Please add a Debugger action to the On Load event and copy and paste the output here.
You will also need a URL for the image to display it in your form, not a path so you'll need to use a Custom Code action to convert from one to the other. Here the key part of the code to do that from the Upload File [GH] action
$save_url = str_replace(JPATH_SITE.DS, JURI::root(), $upload_path);
$save_url = str_replace(DS, '/', $save_url);Bob
Dear Bob,
here is an extract of the debug-info:
Array
(
[Itemid] => 39
[id] => 29
[view] => article
[option] => com_content
[Objekt] => 3
[user_id] => 62
[Objekt_id] =>
[cf_id] => 6
[cf_uid] => 294a40435bcc3629988edbec6057cc39
[cf_created] => 2012-02-01 19:43:50
[cf_modified] => 2012-02-16 13:07:08
[cf_ipaddress] => 87.149.188.81
[cf_user_id] => 62
....
[file1] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_Thomas2.JPG20120205193407_Thomas2.JPG
[file2] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_Thomas1.JPG20120205193407_Thomas1.JPG
[file3] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_profil3.jpg20120205193407_profil3.jpg
[ObjektID] => 3
[freigabe] => Nein
hopefully it helps
Best regards
Thomas
Debug Data
db_record_loader
SELECT * FROM `jos_chronoforms_data_Objekt` AS `ob` WHERE `ObjektID` LIKE '3'
here is an extract of the debug-info:
Array
(
[Itemid] => 39
[id] => 29
[view] => article
[option] => com_content
[Objekt] => 3
[user_id] => 62
[Objekt_id] =>
[cf_id] => 6
[cf_uid] => 294a40435bcc3629988edbec6057cc39
[cf_created] => 2012-02-01 19:43:50
[cf_modified] => 2012-02-16 13:07:08
[cf_ipaddress] => 87.149.188.81
[cf_user_id] => 62
....
[file1] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_Thomas2.JPG20120205193407_Thomas2.JPG
[file2] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_Thomas1.JPG20120205193407_Thomas1.JPG
[file3] => /home/www/web35/html/bnbhu/images/stories/62-3/20120205193407_profil3.jpg20120205193407_profil3.jpg
[ObjektID] => 3
[freigabe] => Nein
hopefully it helps
Best regards
Thomas
Debug Data
db_record_loader
SELECT * FROM `jos_chronoforms_data_Objekt` AS `ob` WHERE `ObjektID` LIKE '3'
Hi Thomas,
That looks OK. The code I gave you should give you the URLs you need.
Bob
That looks OK. The code I gave you should give you the URLs you need.
<?php
$file1_url = str_replace(JPATH_SITE.DS, JURI::root(), $form->data['file1']);
$file1_url = str_replace(DS, '/', $file1_url);
$form->data['image1'] = "<img src='{$file1_url}' />";
?>Then you can turn the the Curly Replacer on in the Show HTML action and add {image1} to your form HTML.Bob
Dear Bob,
thanks for your reply Bob. This helps to get the right format for the field. But the main issue is to check if the field is empty in an user action. the function of empty ($form->data['fieldname']) is every time true. How can I check it in the right way?
best regards
Thomas
thanks for your reply Bob. This helps to get the right format for the field. But the main issue is to check if the field is empty in an user action. the function of empty ($form->data['fieldname']) is every time true. How can I check it in the right way?
best regards
Thomas
This topic is locked and no more replies can be posted.
