Skip to content

--to-default option#18522

Merged
brandonkelly merged 3 commits into5.10from
feature/to-default
Mar 7, 2026
Merged

--to-default option#18522
brandonkelly merged 3 commits into5.10from
feature/to-default

Conversation

@brandonkelly
Copy link
Member

Description

Adds a new --to-default option to resave commands. When present, the field(s) specified by either --set or --with-fields will be set to their default values, when possible.

For example, after setting a default value for a Dropdown field, that default value could be added to all elements that A) have that field; ad B) don’t have a value yet, with the following command:

php craft resave/all --with-field=myDropdownField --to-default --if-empty

This is made possible by a new DefaultableFieldInterface, which is implemented by the following built-in field types:

  • Button Group
  • Checkboxes
  • Color
  • Dropdown
  • Lightswitch
  • Money
  • Multi-select
  • Number
  • Radio Buttons
  • Range
  • Table

Related issues

@brandonkelly brandonkelly changed the title --to-default option --to-default option Mar 7, 2026
@brandonkelly brandonkelly merged commit ceae64f into 5.10 Mar 7, 2026
@brandonkelly brandonkelly deleted the feature/to-default branch March 7, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant