1

i'm having trouble passing boolean values ​​from php to smarty:

php:

if ($Scad['inc']==TRUE){
   $inc = TRUE;
}else{
   $inc = FALSE;
}

smarty template:

{if $inc===true}
   {assign var='bg_color' value='cyano-background'}
{/if}

i get:

Warning: Trying to access array offset on null

what am i doing wrong?

1
  • (a) Is $Scad actually set to anything in php? (b) Are you calling $form->assign('inc', $inc); or equivalent anywhere so that smarty knows what $inc is?
    – Demerit
    Commented Sep 27 at 23:03

2 Answers 2

1

yes I tried to report only the essentials... maybe I exaggerated, but I solved it anyway... I wasted hours and I didn't understand what was wrong (I'm new with smarty)... on the template the variable name was wrong (damn copy-paste) :)

0

I don't see any actual assignment happening in your php. Your php code (which btw is 5 lines that could easily be reduced to 1 since it simply copies the value to another variable without changing it) should look like:

$smarty->assign('inc', $Scad['inc']);

Where $smarty is your reference to CRM_Core_Smarty::singleton().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.