no problem at all.... :)

Let me try and walk you through the edit-text widget as I understand and 
more knowledgeable people around can pitch in to correct me if I have got 
this wrong...

As I understand the most basic usage of the widget would be to place the 
widget in a tiddler like so:

<$edit-text 
tiddler="name_of_data_tiddler_other_than_one_where_this_widget_is_present" 
tag="input_or_textrea"  type="html_field_type" index="some-index-name"/>

Now if we want to make just a simple form above can be repeated a number of 
times with different values for index and it will work. You can check this 
by creating a new tiddler and pasting the following on it:

|Title|Value|h
|!Input Text |<$edit-text tiddler="testdb" placeholder="Input text-field" 
index="field1" size="40"/>|
|!Input Text-index |<$edit-text tiddler="testdb" placeholder="Input 
text-index" index="field2" size="40" tag=input/>|

When you will do this you will notice few things:


   1. field1 is textarea. This is because tag=input is not included in 
   paramenter and if it is not specified by default TW assumes it to be 
   textarea.
   2. As soon as you fill the field the data will keep getting saved on the 
   tiddler "testdb" specified in the parameters
   3. If you open the tiddler "testdb" and edit the values in field on the 
   tiddler with fields you can see the testdb values change with each 
   keystroke.
   4. If you change data on "testdb" tiddler it changes in the field on 
   other tiddler too.

The above behaviour tells us that "testdb" tiddler can effectively be 
treated as backend database for the form on the frontend or so I explained 
it to myself.

So now if I want to store everything on testdb I need to ensure I am giving 
unique names to index which can get crowded and messy so I decided to make 
the backend tiddler change based on name of the frontend tiddler using the 
macro definition which can be done with following line:

\define db() $(currentTiddler)$-db

All this is essentially doing is defining the variable "db" as a string 
"Title of Current Tiddler"-db... So if name of current tiddler is Jake then 
variable db = "Jake-db"

Using this new information we can rewrite the above form as below and see 
how it works:

\define db() $(currentTiddler)$-db
|Title|Value|h
|!Input Text-index |<$edit-text tiddler=<<db>> placeholder="Input 
text-index" index="it" size="40" tag=input/>|
|!First Name |<$edit-text tiddler=<<db>> index="firstname" 
placeholder="First Name"  size="40"/>|
|!Date Field |<$edit-text tag=input type=date tiddler=<<db>> 
index="dt_text"/>|
|!URL Field |<$edit-text tag=input type=url tiddler=<<db>> 
placeholder="https://"; index="dt_URI"/>|
|!Telephone Field |<$edit-text tag=input type=tel tiddler=<<db>> 
placeholder="+4407706811884" index="tel"/>|
|!Email Field |<$edit-text tag=input type=email tiddler=<<db>> 
placeholder="ad...@admin.com" index="email"/>|
|!Colour Field |<$edit-text tag=input type=color tiddler=<<db>> 
placeholder=color index="color"/>|

In above snippet I have now included more field types so you can see how we 
are using various html field types. but more importantly you will notice 
that the parameter tiddler is now calling the macro we defined by using 
<<db>> which in turn is setting the tiddler to Jake-db assuming the tiddler 
where you pasted the above snippet is titled "Jake".

ok so now if you enter some data in the fields created by on tiddler named 
Jake, the data for those fields will be saved in the tiddler named 
Jake-db...

If you have followed this far, you will see that rest of the stuff on my 
previous post's snippet really just adds the functionality to make the form 
editable and view only by including the same fields with help of view 
widget and reveal macro.. tell me if you would want a walk-through of that 
else you are set to proceed :)


On Saturday, 4 July 2020 05:48:32 UTC+1, Jake wrote:
>
>
> If you are trying to create a form, I figured the easiest approach was to 
>> just store the data of your form on a data tiddler. All this can then be 
>> done while giving complete flexibility on different field types. If you 
>> create a form template and then use that template to create new tiddlers 
>> using {{||template}} that should just work.
>>
>> Code below shows examples of various HTML field types :
>>
>  
> Yeah, this could also work, but... I just don't think I'm currently 
> TW-smart enough to understand what is going on here and where. It's easier 
> to deal with 1 field you don't understand functioning then with the whole 
> table you don't understand functioning. :) But I'll definitely save this 
> one and try to understand how to handle it and taylor to my needs. Thank 
> you, Ankit!
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c8284f4d-c174-46d7-a49f-404034233a06o%40googlegroups.com.

Reply via email to