Answers.Body: <p>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) :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-28T06:48:22.687Z
Answers.LastActivityDate: 2024-09-28T06:48:22.687Z
Answers.UserDisplayName: cucca
Answers.Body: <p>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:</p>
  <pre><code>$smarty-&gt;assign('inc', $Scad['inc']);
  </code></pre>
  <p>Where <code>$smarty</code> is your reference to <code>CRM_Core_Smarty::singleton()</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-28T00:49:53.930Z
Answers.LastActivityDate: 2024-09-28T00:49:53.930Z
Answers.UserDisplayName: Coleman
Body: <p>i'm having trouble passing boolean values ​​from php to smarty:</p>
  <p>php:</p>
  <pre><code>if ($Scad['inc']==TRUE){
     $inc = TRUE;
  }else{
     $inc = FALSE;
  }
  </code></pre>
  <p>smarty template:</p>
  <pre><code>{if $inc===true}
     {assign var='bg_color' value='cyano-background'}
  {/if}
  </code></pre>
  <p>i get:</p>
  <pre><code>Warning: Trying to access array offset on null
  </code></pre>
  <p>what am i doing wrong?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-09-27T23:03:51.590Z
Comments.Text: (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?
Comments.UserDisplayName: Demerit
Tags: <php><smarty>
Title: php to smarty boolean vars
ThreadText: # php to smarty boolean vars
  
  (Asked by: username_0 on 2024-09-27)
  
  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?
  
  **Tags:** php, smarty
  
  > **Comments:**
  > **username_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?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2024-09-28. Score: 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) :)
  
  
  ---
  
  ### Answer by username_2 on 2024-09-28. Score: 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()`.
  
  
  ---
  
  