Create new tiddlers using tiddler creation forms based on a template tiddler

I tried to create new tiddlers based on a template tiddler using a tiddler creation form as shown here

I tried this code.

!!Step 1 - ''Give the tiddler a name'' 

---
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='name_temp' placeholder='Tiddler Name'/><br>

!!Step 2 - ''Fill in tiddler text''

---

<$edit-text class='tc-edit-texteditor' tiddler='templatetiddler' field='text' placeholder='Tiddler Text'/><br>

!!Step 3 - Add fields

---

Description : <$edit-text class='tc-edit-texteditor' tiddler='' field='{{templatetiddler!!description}}' placeholder='Tiddler Description'/><br>

or 

Category : <$edit-text class='tc-edit-texteditor' tiddler='templatetiddler' field='category' placeholder='Tiddler category'/><br>


!!Step 4 - ''Create the tiddler''

---
Press this button and the tiddler will be created and opened so you can view it.

<$button>Create Tiddler
<$action-setfield $tiddler={{$:/state/NewTiddlerForm!!name_temp}} text={{$:/state/NewTiddlerForm!!text}} description={{$:/state/NewTiddlerForm!!description}} tags={{$:/state/NewTiddlerForm!!tags}}/>
<$action-navigate $to={{$:/state/NewTiddlerForm!!name_temp}}/>
<$action-setfield $tiddler='$:/state/NewTiddlerForm' name_temp='' text='' description='' tags=''/>
</$button>
<$button>Clear Form
<$action-setfield $tiddler='$:/state/NewTiddlerForm' name_temp='' text='' description='' tags=''/>
</$button>

I want the new tiddlers to have fields as in the template tiddler. For this I tried two approaches given below.

Description : <$edit-text class='tc-edit-texteditor' tiddler='' field='{{templatetiddler!!description}}' placeholder='Tiddler Description'/><br>

or 

Category : <$edit-text class='tc-edit-texteditor' tiddler='templatetiddler' field='category' placeholder='Tiddler category'/><br>

Template tiddler has many fields. So will I have to repeat the code given above for each of the fields. Or is it possible to auto populate the fields of the template tiddler without having to write code for each field separately

I don’t understand this. Where would the values of the fields come from, if the user doesn’t fill the form ?

Fred

See the recent conversation Cloning a tiddler

The ActionCreateTiddlerWidget can create a tiddler based on a template.

There are, I think, at least 3 ways to create tiddlers, and they each have slightly different characteristics.

Code to fill the title, text and fields are there in the beginning

!!Step 1 - ''Give the tiddler a name'' 

---
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='name_temp' placeholder='Tiddler Name'/><br>

!!Step 2 - ''Fill in tiddler text''

---

<$edit-text class='tc-edit-texteditor' tiddler='templatetiddler' field='text' placeholder='Tiddler Text'/><br>

!!Step 3 - Add fields

---

Description : <$edit-text class='tc-edit-texteditor' tiddler='' field='{{templatetiddler!!description}}' placeholder='Tiddler Description'/><br>

or 

Category : <$edit-text class='tc-edit-texteditor' tiddler='templatetiddler' field='category' placeholder='Tiddler category'/><br>


I tried the tm-new-tiddler widget

!!Step 1 - ''Give the tiddler a name'' 

---
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='name_temp' placeholder='Tiddler Name'/><br>

!!Step 2 - ''Text field''

---

<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='text' default='' placeholder='Tiddler Text'/><br>

!!Step 3 - ''Fields''

---

year: <$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='year' default='' placeholder='year'/><br>


!!Step 5 - ''Create the tiddler''

---

<$button>
<$action-sendmessage $message="tm-new-tiddler" $tiddler={{$:/state/NewTiddlerForm!!name_temp}} $param="Year" year={{$:/state/NewTiddlerForm!!year}} />
New Tiddler
</$button>


I have a template tiddler called “Year” with more than 20 fields and some code in the text field. So I used $param=“Year” in the tm-new-tiddler widget for creating the new tiddlers based on the template Year. The problem is that I want the title and some of the field values to be manually input using a form because those will be different for each of the newly being created tiddlers. For which I have added the code given below

!!Step 1 - ''Give the tiddler a name'' 

---
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='name_temp' placeholder='Tiddler Name'/><br>

!!Step 3 - ''Fields''

---

year: <$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='year' default='' placeholder='year'/><br>

But the newly created tiddlers are not showing the manually input tittle and field values. Instead tittle and field values shown are same as the template tiddler Year. So this code must be wrong. Is there any way around.

Here is a demo wiki to check it out.
Click on the button next to the create new year tab to see the form and the form tiddler is this

Finally got this one to work. Relieved !!!

!!Step 1 - ''Give the tiddler a name'' 

---
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='name_temp' placeholder='Tiddler Name'/><br>

!!Step 2 - ''Text field''

---

<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='text' placeholder='Tiddler Text'/><br>

!!Step 3 - ''Fields''

---

year: <$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTiddlerForm' field='year' default='' placeholder='year'/><br>


!!Step 5 - ''Create the tiddler''

---


<$button>
 <$action-createtiddler $basetitle= {{$:/state/NewTiddlerForm!!name_temp}} $overwrite="yes" $template="Year" text={{Year!!text}} year={{$:/state/NewTiddlerForm!!year}}> 
</$action-createtiddler>
Create new year
</$button>

Thanks for you follow-up in this thread, followup helps out community a lot., your wiki looks great. Please consider publishing an “edition” when complete.

A tip for your buttons,

  • adding the class attribute to buttons as follows presents only the icon without the grey box, class="tc-btn-invisible" but it is a matter of style.
1 Like

Is there any way to delete the values stored in the fields of state tiddler, once the new tiddler is created using the form. There is doubling of field values in the dynamic table I am using because the state tiddlers are retaining the filed values.

Use the action set field widget, with the fieldname and value eg text="" temp=""…

Sometimes it makes sense to clear temporary fields, sometimes its convent to retain them when creating multiple items, in this perhaps a separate button to “clear the form”.