Checkbox in signup.html

Discussion in 'Templates customization' started by mediahackers, Jul 13, 2007.

  1. mediahackers

    mediahackers New Member

    Joined:
    Jul 3, 2007
    Messages:
    10
    Hi there all

    I'm adding a custom field into signuup.html thus:

    <tr>
    <th><b>Security at premises</b><br />


    <div class="small">please give details of any cats at the premises</div></th>
    <td>
    <input type=hidden name="sec_check[]" value="{$smarty.request.sec_check|escape}" />
    <label><input type="checkbox" name="sec_check[]" value="IA" />Bengal</label><br />
    <label><input type="checkbox" name="sec_check[]" value="GOS" />lion</label><br />
    <label><input type="checkbox" name="sec_check[]" value="GC" />Tiger</label><br />
    </td>
    </tr>

    Quick question - is the {$smarty.request.sec_check|escape} placed correctly to get this working?

    Thanks

    M
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    No you need to do something like:
    <label><input type="checkbox" name="sec_check[]" value="IA" {if $smarty.request.sec_check == 'IA'}checked{/if}/>Bengal</label><br />
  3. mediahackers

    mediahackers New Member

    Joined:
    Jul 3, 2007
    Messages:
    10
    Return correct value for checkbox in user_profile.html

    Thanks Alex - so why isn't

    <input type=hidden name="work_pattern[]" value="{$u.data.work_pattern|escape}" />
    <label><input type="checkbox" name="work_pattern[]" value="DT" {if $u.data.work_pattern == "DT"}checked="checked"{/if} />Day Times</label><br />
    <label><input type="checkbox" name="work_pattern[]" value="NT" {if $u.data.work_pattern == "NT"}checked="checked"{/if} />Night Times</label><br />
    <label><input type="checkbox" name="work_pattern[]" value="SW" {if $u.data.work_pattern == "SW"}checked="checked"{/if} />Shift Work - variable</label><br />

    returning the correct checked option in the admin profile page having edited user_profile.html template? Is the value messing things up?

    Thanks so much
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Sorry my mistake,
    use this instead:
    {if in_array("DT",$u.data.work_pattern)}
    this field is an array in this case.

Share This Page