Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle field conditionals on frontend don't handle defaults correctly #510

Closed
robinsowell opened this issue Sep 4, 2020 · 2 comments · Fixed by #3278
Closed

Toggle field conditionals on frontend don't handle defaults correctly #510

robinsowell opened this issue Sep 4, 2020 · 2 comments · Fixed by #3278
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. EE5 EE6

Comments

@robinsowell
Copy link
Contributor

Description of the problem
Frontend conditionals don't correctly handle default values for entries that have not been saved with the field.

How To Reproduce
Steps to reproduce the behavior:

Per the cp instructions when creating a toggle field:

Default value
The default position of the toggle switch for this field when publishing new entries.
Note: If assigned to a channel with existing entries, those entries will be assigned this value.

So existing entries should all act as if they were assigned the default value.

Make a new toggle field, set the default to 'on' and assign the field to a channel. Go to edit an existing entry - the toggle field correctly displays as 'on'.

Go make a template:

<h3>{title}</h3>
{if ! show_me} I am hidden!{/if}
{/exp:channel:entries}

All existing entries show the 'I am hidden' text. New entries set to 'on' work (nothing shows up) and new entries set to 'off' show the hidden message. But it's incorrectly defaulting for entries that have not been explicitly set to off.

Environment Details:

  • Version: [e.g. 5.3.2]
@robinsowell robinsowell added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label Sep 4, 2020
@stinhambo
Copy link

This happens in EE 6.0.0 too. To set the toggle to off, I have to toggle on then off again.

@intoeetive
Copy link
Contributor

When you add a field, there is this note:

Note: If assigned to a channel with existing entries, those entries will be assigned this value.

which is definitely not true - it does not create new rows in exp_channel_data_field_X table. It does create those when you run search reindex, so I think we should just put a warning about "search reindex needed" after you add a field (since this can be memory consuming process that we run with AJAX)

intoeetive added a commit that referenced this issue Apr 14, 2023
…oggle field after adding it and no prompt for update were made
intoeetive added a commit that referenced this issue Apr 14, 2023
…oggle field after adding it and no prompt for update were made

(cherry picked from commit 1d64547)
intoeetive added a commit that referenced this issue Apr 24, 2023
…oggle field after adding it and no prompt for update were made

(cherry picked from commit 1d64547)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. EE5 EE6
Projects
None yet
3 participants