Fixing string return in CALC element

mkainz

Member
Ok i've got a field and a calc element.

When in a field i write something like: A Warrior's Life



in the calc element that contains:
$value = '{table___field}';

it gives error for the: ' character.
How can i fix it?
 
Yup, that's a know problem with placeholders. Remember that the placeholders aren't being processed by PHP, rather Fabrik replaces them in the text of your code, before handing the code to PHP to eval. So ...

Code:
$value = '{table___field}';

... we replace the placeholder in the text, which then becomes ...

Code:
$value = 'some string with 'single quote in it';

... which we then pass to PHP. Which errors out because of the mismatched quotes.

There is no really satisfactory workaround, because there's nothing you can do in your code to work round it. Your code doesn't run till the replacement has already happened.

The only workaround is if you know you are working with single quotes in your data, then use double quotes in your code ...

Code:
$value = "{table___field}";

The only real solution would be for us to add escaping of quotes to our replacement code, but that opens a whole can of backward compat worms.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top