1

I have this code in safecracker registration form

<select required name="gender" data-content="{instructions:gender}" data-title="Help" data-placement="right" data-trigger="focus" id="gender">
    <option value=""></option>
    {exp:channel:entries channel="genders" disable="categories|category_fields|member_data|pagination" orderby="entry_id" sort="asc" dynamic="no"}
        <option value="{entry_id}">{gender_name}</option>
    {/exp:channel:entries}
</select>

When I first load the page, it outputs correct entry_ids for the gender.

The problem arises when I try to submit a form that causes an error. I get redirected to the same page but the difference is that in the field above, ALL entry_ids are 0.

<select required name="gender" data-content="{instructions:gender}" data-title="Help" data-placement="right" data-trigger="focus" id="gender">
    <option value=""></option>
    <option value="0">Male</option>
    <option value="0">Female</option>
</select>

Any idea why this is the case?

EDIT: I forgot to say that this code is in a Snippet. It probably is relevant to the discussion.

1 Answer 1

1

My guess this is an EE parse order issue. Assuming you are registering for a new member, the default entry_id is obviously 0 since there is no entry yet. Safecracker is actually parsing the entry_id incorrectly before your entries loop runs. This should have nothing to do with Safecracker Registration, as the same thing would happen with a regular SC form too.

You have two options:

1) Use my Entries addon and prefix your nested tag so there is no parsing conflict. Entries is stable, I just haven't actually released it yet.

https://objectivehtml.com/entries

2) Use Stash to parse that entries loop outside of the Safecracker tag.

Let me know if you have any more questions.

1
  • The code is in a snippet btw. Commented Jul 15, 2013 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.