2

I have a registration form on my frontend and when people click register but the form fails (due to the username already existing for example) I would like to keep all info they entered in the form so they don't need to enter all their data again while editing the form input that gave the error.

I know that there is an account model which you can use to keep all the info into the inputs. I used the official example as a source.

{%- if account is defined %} value="{{ account.fieldName}}"{% endif -%}>

Then I found this for checkboxes but for some reason it doesn't seem to work. I used this in my code (receiveNewsletter is a lightswitch in Craft / checbox on the frontend):

{%- if account is defined and account.receiveNewsletter == "1" %}checked{% endif -%}

But it always seems to return TRUE.

And I have no idea how to handle this for select inputs. Can anyone get me back on track please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.