Skip to content

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

Description

@robinsowell

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]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: AcceptedBug has been confirmed, is reproducible, and ready to work on.EE5EE6

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions