Override how fields are edited when some condition applies

Hello. I am overriding how some fields are edited by following these instructions.

I want to make the decision whether to override based on two pieces of information:

  • Name of the field
  • Whether the tiddler has an attribute prediction-type defined

So far I’ve only be able to do it based on the name of the field by defining this tiddler:

title: $:/plugins/sortega/tiddlypredict/config/field-editors
tags: $:/tags/FieldEditorFilter
list-before: $:/config/FieldEditorFilters/default

[match[prediction]then[$:/plugins/sortega/tiddlypredict/config/FieldEditorFilters/prediction]]
[match[resolution]then[$:/plugins/sortega/tiddlypredict/config/FieldEditorFilters/resolution]]

Is this possible?

Hi @sortega

The doc says that <<currentTiddler>> is available, so you should be able to use [<currentTiddler>has[prediction-type]] somewhere in your filters.

Also, your code example shows 2 filters in a single filter tiddler, I recommend you use one tiddler per filter.

Hope this helps :slightly_smiling_face:

Fred

I’ve added :filter[<currentTiddler>has[prediction-type]] to the filter and it’s not working. Is there any way to debug what’s the value of currentTiddler in such filter?

I suspect that currentTiddler is available for the tiddler generating the field editor and not the cascade but I don’t know how to know for sure.

@Yaisog has written a debug-log filter which might be useful: Introducing the debug-log[] filter

1 Like

The debug-log filter was amazing to debug the problem.
In the cascade, currentTiddler is bound to the name of the field to be edited but storyTiddler to the tiddler itself.

Finally, the correct snippet was :filter[<storyTiddler>has[prediction-type]].

Thanks @tw-FRed!

Reading the storyTiddler documentation (https://tiddlywiki.com/#storyTiddler%20Variable), I understand that it’s available in your case because it’s the edit-mode field editor cascade, but not in every other cascade, although I think it would be useful to have such a variable in every case…