craft-preparse-field icon indicating copy to clipboard operation
craft-preparse-field copied to clipboard

Allow manual override?

Open KatieMFritz opened this issue 4 years ago • 1 comments

I'd like to use PreParse to pull in data from another element, but then allow an author to optionally edit that text.

Is there a way to accomplish this?

KatieMFritz avatar Nov 15 '19 01:11 KatieMFritz

@KatieMFritz I would also LOVE to see this, and actually came to file the same feature request!

I could imaging that the field has a mode called "override", and that would leave the parsed value as placeholder text. The simplest change would probably be to leave the field editable, and if you type something in manually, that value would be stored for the field.

One problem I see is that it would be a bit tricky to combine with the option of updating the field when the element is saved, as it would be impossible to know (when the field's value differ from what the twig code would produce) whether it is "out of sync" because it is manually overridden, or because the value it calculates has changed (for instance, if you're reading a value from another element).

I see that the in the current implementation, the twig code is stored in the project config (as it's always the same for every use of the field), and the actual processed value is stored in the DB as plain text, which makes it easy to retrieve the value like any other in frontend templates, etc. So that would perhaps need to change, at the very least there needs to be some sort of flag to know whether the field is overridden or not.

One kind of workaround, when going the "placeholder" text route, would be that when editing an entry, the field would show if the stored value differs from what the twig would produce. But that would only help when you are manually updating the entries, not if you programatically save a bunch of entries, and would like them to update their values accordingly.

kristiansp avatar Oct 31 '20 12:10 kristiansp