Forums

Curly Brackets and No Data Returned

swmckay 30 Sep, 2011
Hello,

I have inserted some curly brackets, {field},into the Field Default Value entry in order to load data from a table and it is pulling the info properly. However, when there is no data found it logically comes back with {field}. Is there a way to load an empty space instead of {field} when there isn't any data?

Thanks
GreyHead 30 Sep, 2011
Hi swmckay,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

The DB Record Loader in CFv4 should handle that case OK.

Bob
swmckay 30 Sep, 2011
Greyhead,

Yes I am using CFv4. It loads correctly if there is data in the record but when there is no data it comes back with the Default Field Value such as {field}. Perhaps I have added it to the field when I set it up.
GreyHead 01 Oct, 2011
Hi swmckay ,

I'm a bit surprised that you don't get an empty value but don't have time to go digging in the code right now.

I think that a workaround is to add a Custom Code action after the DB Load and before the Show HTML
<?php
if ( !isset($form->data['field']) ) {
  $form->data['field'] = '';
}
?>

Bob
Max_admin 05 Oct, 2011
Hi,

Indeed this is how the curly brackets replacer works, it tries to replace the existing data array keys, it can't predict non existent ones, I suggest that you do something in the "no record found event".

Also, there is no reason you would insert curly brackets into the field default values, the values would be set automatically if there are matching data keys, and if not then they would be left empty, so the simplest answer is to remove those curly brackets strings.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
swmckay 15 Oct, 2011
Hello,

I removed the unnecessary curly bracket entries and problem solved. Thank you gentlemen!
This topic is locked and no more replies can be posted.