Jump to content

setValue for checkboxes FormField not working to get it 'checked'


Recommended Posts


I am using PS

I have this hook to add a checkbox to the registration form which works fine on the account creation form: 

    public function hookAdditionalCustomerFormFields() {
        if($this->context->customer->getGroups()[0] == 4) $v = true;
        else $v = false;

        return [
                    (new FormField)
                    ->setLabel($this->l('Je suis un professionnel')),


Unfortunately, the setValue field is never passed to the tpl (below), even when I just hardcode the value to 1 so it's never checked! Kind of an issue on the form when the user 'edit' his account

   {elseif $field.type === 'checkbox'}

        {block name='form_field_item_checkbox'}
          <span class="custom-checkbox">
              <input name="{$field.name}" type="checkbox" value="1" {if $field.value}checked="checked"{/if} {if $field.required}required{/if}>
              <span><i class="material-icons rtl-no-flip checkbox-checked">&#xE5CA;</i></span>
              {$field.label nofilter}

Thanks for your help. 


Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...