I ran into the issue discussed here: > popup of tiddler with <<formTiddler>> missing contents <https://groups.google.com/forum/#!topic/tiddlywiki/aon14ZtUGZ4>
where the fields in a form tiddler appear blank from within a transclusion.
Eric said the issue stems from the lookup function
(story.findContainingTiddler) that the FormTiddlerPlugin uses to identify
the tiddler in which the formTiddler and <data>...</data> block are stored,
which always returns the title of the outermost containing tiddler.
In the case of a transclusion this becomes the tiddler that invokes the
<<tiddler>> macro rather than the actual source tiddler containing the form
and data.
As a workaround, Eric posted a modified
config.macros.formTiddler.getContainingTiddlerName function with logic to
find the transcluded tiddler.
However, this breaks non-transcluded form tiddlers, and the thread doesn't
go into any further fixes.
SO, I am wondering if we can enhance the logic of "FormTiddlerPluginTweak"
to be able to tell whether the tiddler is in a transclusion or not,
and if it is, use Eric's new logic, else use the original logic...
To do this, I think we would just need a function "tiddlerIsNotTranscluded"
that returns true if the tiddler is NOT inside a transclusion...
Any ideas how this can be done?
*PS *here are the tiddlers to recreate the problem, and the workaround
plugin "FormTiddlerPluginTweak" (which is disabled - to see it in action,
remove the systemConfigDisable tag).
*PPS *Also I am including the tiddlers you can import into your classic
TiddlyWiki (2.6.1 or newer) - either save the attached file or save the
HTML at the bottom and use the import plugin.
################################################################################################################################################################
*Title:*transcluded formTiddler missing contents test fix
*Tags :*tw test
*Body :*
+++(formTiddler-transclude-fix-test-1)[Edit Problem1|click to open][Hide
Problem1|click to close]<<tiddler Problem1>>===<br>
+++(formTiddler-transclude-fix-test-2)[Edit Problem2|click to open][Hide
Problem2|click to close]<<tiddler Problem2>>===<br>
+++(formTiddler-transclude-fix-test-3)[Edit Problem3|click to open][Hide
Problem3|click to close]<<tiddler Problem3>>===<br>
################################################################################################################################################################
*Title:*Problem1
*Tags :*tw test
*Body :*
<<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This is
some test content for Problem1."}</data>
################################################################################################################################################################
*Title:*Problem2
*Tags :*tw test
*Body :*
<<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This is
some test content! (For Problem2.)"}</data>
################################################################################################################################################################
*Title:*Problem3
*Tags :*tw test
*Body :*
<<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"Problem3
test content."}</data>
################################################################################################################################################################
*Title:*TextAreaTemplate010Rows080ColsWrapOffCourier12
*Tags :*FormTiddlerProject formTemplate
*Body :*
<html><TEXTAREA name="notes" rows="10" cols="80" WRAP="OFF"
STYLE="font-size:12px; font-family: Courier;Courier
New,Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans
Mono,Bitstream Vera Sans Mono,monospace;" ></TEXTAREA></html>
################################################################################################################################################################
*Title:*FormTiddlerPluginTweak
*Tags :*systemConfig systemConfigDisable
*Body :*
/*
FROM: https://groups.google.com/forum/m/#!topic/tiddlywiki/aon14ZtUGZ4
Subject: popup of tiddler with <<formTiddler>> missing contents
UPDATES FUNCTION IN FormTiddlerPlugin:
config.macros.formTiddler.getContainingTiddlerName = function(element) {
return story.findContainingTiddler(element).id.substr(7);
}
5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>> macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig'
...
PLUS: as an added bonus, because 'transclusion' via the <<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak' should
also fix the same problem when using forms from within tabs!
------------------------------------------
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
------------------------------------------
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with this
tweak installed, my form <data> that is inside <part></part> still
doesn't display?
------------------------------------------
MadSciJr: so given the above, I am wondering if we can enhance the logic
to be able to tell whether the tiddler is in a transclusion or not,
and if it is, use Eric's new logic, else use the original logic...
To do this we need a function "tiddlerIsNotTranscluded" that returns true
if the tiddler is NOT inside a transclusion...
*/
// Internal.
//
// Returns the name of the tiddler containing the given element.
//
// Internal.
//
// Returns the name of the tiddler containing the given element.
//
config.macros.formTiddler.getContainingTiddlerName = function(e) {
// if (tiddlerIsNotTranscluded(???))
// {
// // USE ORIGINAL LOGIC
// return story.findContainingTiddler(element).id.substr(7);
// }
// else
// {
// // USE ENHANCED LOGIC:
// find transcluded OR containing tiddler
while(e && !e.getAttribute("tiddler"))
e=e.parentNode;
return e?e.getAttribute("tiddler"):e;
// }
};
################################################################################################################################################################
*5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>> macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig'
...
PLUS: as an added bonus, because 'transclusion' via the <<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak' should
also fix the same problem when using forms from within tabs!
------------------------------------------
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
------------------------------------------
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with this
tweak installed, my form <data> that is inside <part></part> still
doesn't display?
------------------------------------------
MadSciJr: so given the above, I am wondering if we can enhance the logic
to be able to tell whether the tiddler is in a transclusion or not,
and if it is, use Eric's new logic, else use the original logic...
To do this we need a function "tiddlerIsNotTranscluded" that returns true
if the tiddler is NOT inside a transclusion...*
<html><body><style type="text/css"> #storeArea
{display:block;margin:1em;} #storeArea div
{padding:0.5em;margin:1em;border:2px solid
black;height:10em;overflow:auto;} #pureStoreHeading
{width:100%;text-align:left;background-color:#eeeeee;padding:1em;}
</style><div id="pureStoreHeading"> TiddlyWiki "PureStore" export file
<br> Source: <b>file:///C:/Temp/TiddlyWiki_2.6.1.html</b><br> Title:
<b>My TiddlyWiki</b><br> Subtitle: <b>a reusable non-linear personal web
notebook</b><br> Created: <b>8/11/2015, 3:02:21 PM</b> by <b>madscijr
</b><br> TiddlyWiki 2.6.1 / ExportTiddlersPlugin 2.8.4<br> Notes:
<hr><pre></pre></div><div id="storeArea">
TextAreaTemplate010Rows080ColsWrapOffCourier12
<div title="TextAreaTemplate010Rows080ColsWrapOffCourier12" creator=
"madscijr" modifier="madscijr" created="201507092031" modified=
"201508111900" tags="FormTiddlerProject formTemplate" changecount="8"
alias="[[TextAreaTemplate10Rows080ColsWrapOffCourier12]]
[[TextAreaTemplate10Rows80ColsWrapOffCourier12]]">
<pre><html><TEXTAREA name="notes" rows="10"
cols="80" WRAP="OFF" STYLE="font-size:12px;
font-family: Courier;Courier New,Consolas,Monaco,Lucida Console,Liberation
Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace;"
></TEXTAREA></html></pre>
</div>
FormTiddlerPluginTweak
<div title="FormTiddlerPluginTweak" modifier="madscijr" created=
"201508111812" modified="201508111851" tags="systemConfig
systemConfigDisable" changecount="3" alias="">
<pre>/*
UPDATES FUNCTION IN FormTiddlerPlugin:
config.macros.formTiddler.getContainingTiddlerName = function(element) {
return story.findContainingTiddler(element).id.substr(7);
}
5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the
form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block
are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>>
macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the
transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that
was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig'
...
PLUS: as an added bonus, because 'transclusion' via the
<<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak'
should
also fix the same problem when using forms from within tabs!
------------------------------------------
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
------------------------------------------
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with
this
tweak installed, my form <data> that is inside
<part></part> still
doesn't display?
------------------------------------------
MadSciJr: so given the above, I am wondering if we can enhance the logic
to be able to tell whether the tiddler is in a transclusion or not,
and if it is, use Eric's new logic, else use the original logic...
To do this we need a function "tiddlerIsNotTranscluded" that returns true
if the tiddler is NOT inside a transclusion...
*/
// Internal.
//
// Returns the name of the tiddler containing the given element.
//
config.macros.formTiddler.getContainingTiddlerName = function(e) {
// if (tiddlerIsNotTranscluded(???))
// {
// // USE ORIGINAL LOGIC
// return story.findContainingTiddler(element).id.substr(7);
// }
// else
// {
// // USE ENHANCED LOGIC:
// find transcluded OR containing tiddler
while(e && !e.getAttribute("tiddler"))
e=e.parentNode;
return e?e.getAttribute("tiddler"):e;
// }
};
/*
FROM:
popup of tiddler with <<formTiddler>> missing contents
https://groups.google.com/forum/m/#!topic/tiddlywiki/aon14ZtUGZ4
5/22/09 Dave
Hi,
I have a tiddler with a nested slider popup like this
+++^* <<tiddler Problem1>> ===
and the tiddler called "Problem1" has this in it:
<<formTiddler
ProblemTemplate>><data>{"location":"sdfgsdfg","referral
to":"elbow","course":"better"}</data>
When I click the slider to show the pop-up, the little box around the
pop-up only borders part of the tiddler, and the field boxes extend
beyond the right border and are empty. When I open the tiddler
normally it is fine.
Any ideas?
Thanks,
DP
5/22/09 Eric Shulman
> +++^* <<tiddler Problem1>> ===
> When I click the slider to show the pop-up, the little box around the
> pop-up only borders part of the tiddler, and the field boxes extend
> beyond the right border and are empty. When I open the tiddler
> normally it is fine.
Try specifying a fixed width for the floating slider panel:
+++^40em^* <<tiddler Problem1>> ===
-e
5/22/09 cmari
The slider isn't really the issue. The problem is that data in a form
tiddler does not appear in transclusion (e.g., when using the
<<tiddler>> macro) - all you can see is the outline of the
form, not
the contents of the form fields. The only way I've been able to make
the <<tiddler>> macro display the contents of forms is by adding
another macro inside the form tiddler like <<showData>> or a
fET macro
that calls up the data and puts it into a table (inside the form
tiddler itself, so that the data is effectively displayed twice in
that tiddler - though it can be hidden in a slider). I'd be
interested to hear about other solutions!
cmari
- show quoted text -
5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the
form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block
are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>>
macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the
transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that
was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig', with the
following replacement code:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(e) {
// find transcluded OR containing tiddler
while(e && !e.getAttribute("tiddler"))
e=e.parentNode;
return e?e.getAttribute("tiddler"):e;
};
------------------------------------------
PLUS: as an added bonus, because 'transclusion' via the
<<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak'
should
also fix the same problem when using forms from within tabs!
Give it a try and let me know what happens...
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
5/23/09 Dave
I think you're on to something...
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
Thanks,
Dave
- show quoted text -
5/23/09 cmari
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with
this
tweak installed, my form <data> that is inside
<part></part> still
doesn't display?
cmari
- show quoted text -
5/27/09 Dave
Okay, I've tried something different to try to get this idea to work:
I was wondering if I could do the same thing with custom fields
instead of FormTiddler data, so I learned how to use custom fields and
"hide when". Unfortunately I forgot that the custom fields don't
display inside the main tiddler body. Is there a way to get a custom
field to show up with a <<tiddler TiddlerName>>?
Dave
- show quoted text -
> > > TiddlyTools / ELS Design Studios- Hide quoted text -
>
> - Show quoted text -
*/
</pre>
</div>
transcluded formTiddler missing contents test fix
<div title="transcluded formTiddler missing contents test fix" modifier=
"madscijr" created="201508111800" modified="201508111840" tags="tw test"
changecount="9" alias="">
<pre>+++(formTiddler-transclude-fix-test-1)[Edit Problem1|click to
open][Hide Problem1|click to close]<<tiddler
Problem1>>===<br>
+++(formTiddler-transclude-fix-test-2)[Edit Problem2|click to open][Hide
Problem2|click to close]<<tiddler Problem2>>===<br>
+++(formTiddler-transclude-fix-test-3)[Edit Problem3|click to open][Hide
Problem3|click to close]<<tiddler Problem3>>===<br>
</pre>
</div>
Problem3
<div title="Problem3" creator="madscijr" modifier="madscijr" created=
"201508111803" modified="201508111803" tags="tw test" changecount="1" alias=
"">
<pre><<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"Problem3
test content."}</data></pre>
</div>
Problem2
<div title="Problem2" creator="madscijr" modifier="madscijr" created=
"201508111802" modified="201508111803" tags="tw test" changecount="1" alias=
"">
<pre><<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This
is some test content! (For Problem2.)"}</data></pre>
</div>
Problem1
<div title="Problem1" modifier="madscijr" created="201508111802" modified=
"201508111802" tags="tw test" changecount="1" alias="">
<pre><<formTiddler
TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This
is some test content for Problem1."}</data></pre>
</div></div><!--POST-BODY-START-->
<!--POST-BODY-END--></body></html>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/acd4c3b2-291e-4a42-b056-70b4f1b9650f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TiddlyWiki "PureStore" export file
Source: file:///C:/Temp/TiddlyWiki_2.6.1.html
Title: My TiddlyWiki
Subtitle: a reusable non-linear personal web notebook
Created: 8/11/2015, 3:02:21 PM by madscijr
TiddlyWiki 2.6.1 / ExportTiddlersPlugin 2.8.4
Notes:
Source: file:///C:/Temp/TiddlyWiki_2.6.1.html
Title: My TiddlyWiki
Subtitle: a reusable non-linear personal web notebook
Created: 8/11/2015, 3:02:21 PM by madscijr
TiddlyWiki 2.6.1 / ExportTiddlersPlugin 2.8.4
Notes:
TextAreaTemplate010Rows080ColsWrapOffCourier12
FormTiddlerPluginTweak
transcluded formTiddler missing contents test fix
Problem3
Problem2
Problem1
<html><TEXTAREA name="notes" rows="10" cols="80" WRAP="OFF" STYLE="font-size:12px; font-family: Courier;Courier New,Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace;" ></TEXTAREA></html>
/*
UPDATES FUNCTION IN FormTiddlerPlugin:
config.macros.formTiddler.getContainingTiddlerName = function(element) {
return story.findContainingTiddler(element).id.substr(7);
}
5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>> macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig'
...
PLUS: as an added bonus, because 'transclusion' via the <<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak' should
also fix the same problem when using forms from within tabs!
------------------------------------------
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
------------------------------------------
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with this
tweak installed, my form <data> that is inside <part></part> still
doesn't display?
------------------------------------------
MadSciJr: so given the above, I am wondering if we can enhance the logic
to be able to tell whether the tiddler is in a transclusion or not,
and if it is, use Eric's new logic, else use the original logic...
To do this we need a function "tiddlerIsNotTranscluded" that returns true
if the tiddler is NOT inside a transclusion...
*/
// Internal.
//
// Returns the name of the tiddler containing the given element.
//
config.macros.formTiddler.getContainingTiddlerName = function(e) {
// if (tiddlerIsNotTranscluded(???))
// {
// // USE ORIGINAL LOGIC
// return story.findContainingTiddler(element).id.substr(7);
// }
// else
// {
// // USE ENHANCED LOGIC:
// find transcluded OR containing tiddler
while(e && !e.getAttribute("tiddler")) e=e.parentNode;
return e?e.getAttribute("tiddler"):e;
// }
};
/*
FROM:
popup of tiddler with <<formTiddler>> missing contents
https://groups.google.com/forum/m/#!topic/tiddlywiki/aon14ZtUGZ4
5/22/09 Dave
Hi,
I have a tiddler with a nested slider popup like this
+++^* <<tiddler Problem1>> ===
and the tiddler called "Problem1" has this in it:
<<formTiddler ProblemTemplate>><data>{"location":"sdfgsdfg","referral
to":"elbow","course":"better"}</data>
When I click the slider to show the pop-up, the little box around the
pop-up only borders part of the tiddler, and the field boxes extend
beyond the right border and are empty. When I open the tiddler
normally it is fine.
Any ideas?
Thanks,
DP
5/22/09 Eric Shulman
> +++^* <<tiddler Problem1>> ===
> When I click the slider to show the pop-up, the little box around the
> pop-up only borders part of the tiddler, and the field boxes extend
> beyond the right border and are empty. When I open the tiddler
> normally it is fine.
Try specifying a fixed width for the floating slider panel:
+++^40em^* <<tiddler Problem1>> ===
-e
5/22/09 cmari
The slider isn't really the issue. The problem is that data in a form
tiddler does not appear in transclusion (e.g., when using the
<<tiddler>> macro) - all you can see is the outline of the form, not
the contents of the form fields. The only way I've been able to make
the <<tiddler>> macro display the contents of forms is by adding
another macro inside the form tiddler like <<showData>> or a fET macro
that calls up the data and puts it into a table (inside the form
tiddler itself, so that the data is effectively displayed twice in
that tiddler - though it can be hidden in a slider). I'd be
interested to hear about other solutions!
cmari
- show quoted text -
5/23/09 Eric Shulman
> The slider isn't really the issue. The problem is that data in a form
> tiddler does not appear in transclusion (e.g., when using the
> <<tiddler>> macro) - all you can see is the outline of the form, not
> the contents of the form fields.
The problem originates with the 'lookup function' that
[[FormTiddlerPlugin]] is using to identify the tiddler in which the
<<formTiddler>> macro and <data>...</data> block are stored (the
"source" tiddler).
Here's what that function currently looks like:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(element)
{
return story.findContainingTiddler(element).id.substr(7);
}
------------------------------------------
Unfortunately, story.findContainingTiddler() (a standard TW core
function) always returns the title of the *outermost* containing
tiddler -- in this case, the one that invokes the <<tiddler>> macro --
rather than name the actual source tiddler that was transcluded when
that macro was processed. This, of course, produces the results that
you have observed: the plugin is unable to retrieve the form data,
because it is looking in the wrong tiddler!
Fortunately, there may be a relatively easy solution...
The key is to know that, whenever a tiddler is displayed in the story
column, it is contained within a 'wrapper' element that includes a
special "tiddler" attribute that holds the title of the current
tiddler.
Similarly, whenever a <<tiddler>> macro is processed, the transcluded
content is also contained in a wrapper element that has its own
"tiddler" attribute, set to the title of the source tiddler that was
transcluded.
The fix involves re-defining the FormTiddlerPlugin lookup function, so
that it will find the *innermost* wrapper that has a "tiddler"
attribute, and then use *that* value to retrieve the correct
<data>...</data> block.
We can do this by adding an extra tiddler, e.g.,
[[FormTiddlerPluginTweak]], tagged with 'systemConfig', with the
following replacement code:
------------------------------------------
config.macros.formTiddler.getContainingTiddlerName = function(e) {
// find transcluded OR containing tiddler
while(e && !e.getAttribute("tiddler")) e=e.parentNode;
return e?e.getAttribute("tiddler"):e;
};
------------------------------------------
PLUS: as an added bonus, because 'transclusion' via the <<tabs>> macro
works the same way as the <<tiddler>> macro (i.e., it sets the
"tiddler" attribute of the containing wrapper), this 'tweak' should
also fix the same problem when using forms from within tabs!
Give it a try and let me know what happens...
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
5/23/09 Dave
I think you're on to something...
the fix does work for viewing the form tiddler in the pop-up, but it
disables the viewing of the form tiddler in the straight "right from
the tiddler" way...
Any ideas? (he said hopefully :-)
Thanks,
Dave
- show quoted text -
5/23/09 cmari
This is really neat, especially because it's then possible to make
changes to a form while it's being viewed in transclusion!
But as Dave says, the refresh doesn't quite keep up - whenever either
the original tiddler or the transclusion tiddler is changed, the other
tiddler has to be closed and reopened in order to display the change.
Am I correct that the "wrapper" is also the reason why, even with this
tweak installed, my form <data> that is inside <part></part> still
doesn't display?
cmari
- show quoted text -
5/27/09 Dave
Okay, I've tried something different to try to get this idea to work:
I was wondering if I could do the same thing with custom fields
instead of FormTiddler data, so I learned how to use custom fields and
"hide when". Unfortunately I forgot that the custom fields don't
display inside the main tiddler body. Is there a way to get a custom
field to show up with a <<tiddler TiddlerName>>?
Dave
- show quoted text -
> > > TiddlyTools / ELS Design Studios- Hide quoted text -
>
> - Show quoted text -
*/
+++(formTiddler-transclude-fix-test-1)[Edit Problem1|click to open][Hide Problem1|click to close]<<tiddler Problem1>>===<br> +++(formTiddler-transclude-fix-test-2)[Edit Problem2|click to open][Hide Problem2|click to close]<<tiddler Problem2>>===<br> +++(formTiddler-transclude-fix-test-3)[Edit Problem3|click to open][Hide Problem3|click to close]<<tiddler Problem3>>===<br>
<<formTiddler TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"Problem3 test content."}</data>
<<formTiddler TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This is some test content! (For Problem2.)"}</data>
<<formTiddler TextAreaTemplate010Rows080ColsWrapOffCourier12>><data>{"notes":"This is some test content for Problem1."}</data>

