TPL/PHP: Checkbox checked on page load

856 views Asked by At

I need the page to bring this option checked by default in loading the page, but even putting the same check comes in white.

Note that the other field, has a similar structure and comes checked when loading the page.

<tr>
    <td></td><td>
        <input type="checkbox" name="optInventory" 
        {if $gui->projectOptions->inventoryEnabled} checked="checked"  {/if} />
        {$labels.testproject_enable_inventory}
    </td>
</tr>

This is checked by default when loading the page:

 <tr>
    <td></td><td>
        <input type="checkbox" name="is_public" {if $gui->is_public eq 1} checked="checked"  {/if} />
        {$labels.public}
      </td>
  </tr>

image

1

There are 1 answers

0
Quagaar On BEST ANSWER

Output the option value to see if it is really what you expect. Also, I think that Smarty (at least some older versions) don't allow multiple use of -> in an expression. Try to first assign the options to a template variable and then use that in your checkbox:

{assign var=opts value=$gui->projectOptions}
<input type="checkbox" {if $opts->inventoryEnabled}checked="checked"{/if} />