how to display already checked checkboxes

Discussion in 'Templates customization' started by glrfcentral, Mar 30, 2013.

  1. glrfcentral

    glrfcentral aMember Pro Customer

    Joined:
    Mar 19, 2007
    Messages:
    27
    Hi -

    I am using this code to display an additional field in one of our profile templates:

    <tr>
    <th class="headrow" colspan="2">#_TPL_UPDATE_cvcvPREF_CTR#
    </th>
    </tr>
    {php}
    global $member_additional_fields;
    foreach ($member_additional_fields as $field) {
    if ('othercountry'==$field['name']) {
    $this->assign('othercountry_options', $field['options']);
    break;
    }
    }
    {/php}

    <tr>
    <th><b><label for="othercountry">#_TPL_UPDATE_cvcvPREF_CTRY#{$a_req}</label></b><br />
    <div class="small">#_TPL_UPDATE_cvcvPREF_CTRY1#<br />#_TPL_UPDATE_cvcvPREF_CTRY2#</div></th>
    <td>{html_checkboxes name='othercountry' options=$othercountry_options checked=$user.othercountry separator='<br />'}
    </td>
    </tr>
    <tr>
    <th class="headrow" colspan="2">
    </th>
    </tr>

    So ... it works great EXCEPT ... when I return to that profile template, it does not show the previously selected checkboxes. They all appear unchecked. If I view the member profile in the ACP, the selected checkboxes ARE checked.

    Thanks for any advice you can offer.

    Brian
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    I believe your field have "Common" type so correct code to show this field is:
    {html_checkboxes name='othercountry' options=$othercountry_options checked=$user.data.othercountry separator='<br />'}
  3. glrfcentral

    glrfcentral aMember Pro Customer

    Joined:
    Mar 19, 2007
    Messages:
    27
    Oh perfect. Of course, it makes sense. I had gone into the database and seen the entries in the data field of the members table. Thanks.

    Brian

Share This Page