Help Needed with template button

Example at https://sunny-examples.tiddlyhost.com/

I want to create a new tiddler using the button $:/template/edit-field-auto. The button should create a tiddler with editable fields for each field shown in the template, automatically.

The button $:/template/edit-field works as expected as the fields are listed in the body text of the template.

Can you offer any help to resove this issue, as it would be useful to be able to create tiddlers without knowing / listing their individual fields for each tiddler variation.

Thanks in advance.

Hi @Sunny,

You can’t directly use variables inside macrocalls so this code doesn’t work:

<<edit-fieldname <<value>>>>

You should use the <$transclude> widget instead, like this:

<$transclude $variable="edit-fieldname" fieldname=<<value>>/>

which is the new preferred widget for this use case, or you can use the older but still working <$macrocall> widget.

Fred

On your site, the following code works…

<$list filter="[all[current]fields[]prefix[my]]" variable="field">
<$list filter="[all[current]get<field>]" variable="value">
<$transclude $variable="edit-fieldname" fieldname=<<field>>/>
</$list>
</$list>

(I think in addition to what @tw-FRed was noticing, you also were confused about using <<value>> where you needed to use <<field>> toward the end there. — Remember that [get<field>] retrieves the content of the field, and you needed the fieldname instead to show up.)

Remember to tag $:/template/edit-field-auto (and anything else with key definitions of macros / functions / etc.) with $:/tags/Global so that the definitions will be available to other tiddlers.

1 Like

Thank you @tw-FRed for your quick reply.
I haven’t been at my computer today, until now, sorry for the delay in replying. This solves my problem.
I need to read more about variables etc. as I only use snippets of code from what I’ve seen on this forum and from other TW users.
I have attached the updated file below.
$ _template_edit-field-auto.json (643 Bytes)

Thank you @Springer for your example showing how this should be written.
I posted the complete code in my reply to @tw-FRed as the solution was the same as yours, I hope you don’t mind.
The help offered on this forum is much appreciated by novices like myself.
Thanks again to you both.

1 Like