craftcms / craftcms/cms

Field's previous default value being used if changed and set value is cleared out

Open
#3,734 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

Tested with Radio Button and Color field types. Might be an issue with other fields with default values.

When a field is using a default value and that default value is then changed, the previous default value is still used when output in Twig.

Also, the values are then unselected/blank when editing an entry that uses the field and default value.

Steps to reproduce
  1. Create a Radio Button or Color field type with a default value.
  2. Add field to an entry.
    *Note: if the entry is existing you must set or select the default value for it to be applied.
  3. Test to see default value is returned in entry's Twig output.
  4. Change the field's default value.
  5. Edit the entry from step 2, and see that the value is missing.
  6. Test to see that the previous default value is still returned in entry's Twig output.
Additional info
  • Craft version: 3.1.4
  • PHP version: 7.1.12
  • Database driver & version: MySQL 5.6.38

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the problem with Radio Button and Color fields using the listed steps, then trace the field default handling during entry editing and Twig output. Done means changing a field’s default no longer leaves the previous value in output and the entry’s value is not blank when edited.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.