Curly brackets vs $form->data

Ro Rolfo 09 Feb, 2013
Hi all,

I used variable data via curly brackets directly in my query. But after copying the form to a new setup with Joomla 2.5.9 and CF4.0RC3.5.2 the value didn't com through and the queries were unsuccessfull.

Placing a simple $someid = $form->data['someid'] before the old curly bracket location and using a variable instead did the trick for me.

Is it true that curly brackets can not be used in queries anymore?

Cheers,
Rolf
Gr GreyHead 09 Feb, 2013
Hi Rolf,

You've never reliably been able to use curly brackets inside PHP (though it does work in some places).

I follow a rule of thumb to always use $form->data['input_name'] in PHP and keep {input_name} for use in plain HTML.

Bob
Ro Rolfo 09 Feb, 2013
Thanks for the quick reply Bob, I changed all those curlies!

But the cause of all this is still unsolved by me. I had a Custom Code action in the On Load before DB Loader and Show html.

<?php
$user = JFactory::getUser();
$form->data['id_user'] = $user->id;
?>


But that now gives me a "Catchable fatal error: Object of class CFChronoForm could not be converted to string"

When I add the form id like this:

<?php
$user = JFactory::getUser();
$form->data['formidname']['id_user'] = $user->id;
?>


The error is gone and I can request the value by $form->data['formidname']['id_user'] offcourse. But I also had a hidden field for Javascript use, but this field remains empty now!

Is form->data not usable anymore? (with Joomla 2.5.9 php 5.3.10 and Magic Quotes off)
Gr GreyHead 09 Feb, 2013
Hi Rolfo,

What is the full text of the error message?

I use $form->data[] all the time with no problems/.

Bob
Ro Rolfo 10 Feb, 2013
Complete error message on a white page:


Catchable fatal error: Object of class CFChronoForm could not be converted to string in /home/filemaker/domains/xxxxxxxxxxxx/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 3
Gr GreyHead 10 Feb, 2013
Hi Rolfo,

So what is on line 3 of your Custom Code action code?

Bob
Ro Rolfo 10 Feb, 2013
I have so many Custom Code actions that it was quite a puzzle for me. But the one causing the error was this:

<?php
$form = $$form
?>


By removing it, the problem was solved! I don't remember the function of it anyway 😶

Thanks for your guidance Bob!
This topic is locked and no more replies can be posted.