I was looking to customize the edit template, and in particular, the fields section, but only for tiddlers with certain tags.
Looking at the available cascades, I see there is a Field Edit Cascade which allows you to provide your own template for the input of each single field.
The customizations I want to do include:
- Disable the delete button under certain conditions (alternatively, make the delete button empty the field value, without deleting it)
- Conditionally display text underneath the input widget (requiring enough formatting to make the entire table row taller, to accommodate this additional text)
As far as I’m aware, these things cannot be achieved through the field edit cascade. Thus, I’m looking a level higher.
I see that the Edit Template is tagging the following: $:/core/ui/EditTemplate/fields
Using this tagging mechanism, I can add my own components before or after the fields section; however, I want to conditionally replace the fields section. While I would like to do that on a per-field basis, I am okay with replacing the entire thing.
This seems fairly achievable by the following steps:
- Make my customized field editor tiddler
$:/myFieldEditor
- Make a tiddler
$:/myFieldEditorPicker
that transcludes$:/myFieldEditor
under the conditions I want it to (for editing tiddlers with certain tags) and transcludes$:/core/ui/EditTemplate/fields
otherwise. (I think I could even make my own cascade to achieve this.) - Add the tag
$:/tags/EditTemplate
to$:/fieldEditorPicker
and addlist-after: $:/core/ui/EditTemplate/type
- Remove the tag
$:/tags/EditTemplate
from$:/core/ui/EditTemplate/fields
This seems very reasonable, except for that I would have to edit the shadow tiddler $:/core/ui/EditTemplate/fields
to remove the tag. If that tiddler gets updated in a later version of TW, then I would not get the updates when I upgrade my wiki because they will be overridden by a modified version of the old version. From what I understand, that’s why it’s recommended that you never override shadow tiddlers that form core ui components.
But is this really a bad idea? I get that if I modify the text field, then it could be difficult or impossible to merge changes; but in this case, since all I’d be doing is removing a tag, I could simply update the wiki, delete that overridden tiddler, and modify the shadow tiddler to remove the tag again, right?
But on the other hand, if I make my tool available to other users, then putting that burden on them might not be a good idea. (Maybe I could do something similar to the banner telling the user to save and refresh the page after messing with JS tiddlers, but have the banner tell the user to click a button that deletes the overriding tiddler and then recreates it by deleting the tag from the shadow tiddler?)
Thoughts?