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

[4.x] Clarify default field instructions/helper-text #8808

Merged

Conversation

caseydwyer
Copy link
Contributor

This tiny tweak originated in a Discord chat with Erin & Sam. Currently, the fields_default_instructions—which is used for the helper text below Default Value on field definitions—reads as:

Set the default value.

This PR tries to put a lil more meat on dem bones. 🍖 Proposing a change to:

Set a default value. Inserted whenever this field is empty, on all publishable forms.

This is definitely a subjective thing, so won't hurt my feelings if you all decide to reject or edit...but this has bit me a couple of times, with how the setting actually works. Copying in a bit of that Discord convo linked above, for more context:

I tend to think of default as more of a UI consideration—ie, a default value to save the user some time in the GUI, by pre-populating the field at time of creation, with a commonly-used default. And what's actually happening, I would maybe consider more of a fallback that's typically handled via code—ie, a stand-in value, in the event that the user hasn't provided a value and the system needs one, for whatever reason.

The way Statamic actually works is kind of an interesting hybrid, IMHO...it's similar to the former, as it's purely a front-end thing (at least as far as I can tell...nothing seems to be happening server-side to "force" that default into place). But it has the persistence of the latter, as it always attempts to "re-insert" the default, including on edit forms.

So as an example, say a user goes to create a new entry and clears the default value from the field. This saves as expected, with a null value. But if they return to edit that previously-saved entry—ie, any one that has a blank value in the field—the default value will be "quietly" re-entered via the CP GUI. And they might not realize that, causing confusion and/or problems when they unknowingly save a value into that field.

Again, totally realize this is mostly subjective semantics. TBH, would be nice to have both a default and a fallback to serve both purposes. But no biggie—just thought it might be beneficial for all, to have a slightly more descriptive rundown on how that works under the hood.

@caseydwyer
Copy link
Contributor Author

Man just re-read that, and lol at me—context is about 100x as long as the actual code edits. 😂
Whoever gets stuck handling this PR, probably:

image

@jasonvarga
Copy link
Member

It was a good read. Thanks!

@caseydwyer
Copy link
Contributor Author

Haha, no problem—thanks Jason!

@jasonvarga jasonvarga merged commit 72527a3 into statamic:4.x Oct 5, 2023
16 checks passed
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.

2 participants