I used
<input type="hidden" name="action" value="form" />
in my form (also with
templatetopic &
formtemplate parameter) and I expect to edit the form only but bring in my topic template content in background. This background action is work in 4.1.2 but fail in 4.2!
There are 2 test pages:
with and
without "action" parameter in development site. You can find that:
- When without "action" parameter, new created topic has my topic template's content and also has my form attached (below) in it! It looks good!
- When with "action" parameter, content in EvaluationTemplate didn't appear in new created topic!
Another note:
- content in EvaluationTemplate that bring in to new topic without "action" is strange %3C%21--%0A%20%20%20*%20ALLOWTOPICVIEW%20%3D%20Main.MagicYang%0A%20%20%20*%20ALLOWTOPICCHANGE%20%3D%20Main.MagicYang%0A%20%20%20*%20Set%20VIEW_TEMPLATE%20%3D%20Main.PatternSkinUserView%0A--%3E%0A
--
TWiki:Main/MagicYang - 17 Apr 2008
TWikiScripts documents
action=form
as follows:
Use the editaction template instead of the standard edit. If action=text, then hide the form. If action=form hide the normal text area and only edit the form.
To start with I'm not sure what
Use the editaction template is meant to mean. There is no
editaction
parameter and no
editaction
template in the standard template set. There
is a
$editaction
variable in the
Edit.pm
module, so I guess it's referring to this. Reading the code, here's what happens:
The template is determined as follows:
- If the
template
parameter is given, then that is taken, else
- If the EDIT_TEMPLATE TWiki variable is defined, that is taken, else
- the template name is
edit
. This is the case in the example given.
Now the value of the
action
parameter is appended to the template name, so in the example (where
action=form
) the template name is
editform
. There is no
editform.pattern.tpl
so this results in
editform.tmpl
being loaded for the edit.
In 4.1.2 this template included the line
<input type="hidden" id="topic" name="text" value="%TEXT%" />
which would have sufficed to pull the text into the form. However this has been removed from the 4.2.0 templates (
TWikirev:14337 against
Item4142) to cause this bug.
I don't know why this was removed, but a possible workaround is to modify the
editform.tmpl
locally as follows:
Index: editform.tmpl
===================================================================
--- editform.tmpl (revision 16719)
+++ editform.tmpl (working copy)
@@ -7,4 +7,5 @@
%TMPL:DEF{"content"}%%TMPL:P{"formstart"}%%TMPL:P{"formbottom"}%
%TMPL:P{"topicinfo"}%
+<textarea style="display:none" name="text">%TEXT%</textarea>
%TMPL:P{"formend"}%%TMPL:END%
This really needs Arthur to review my analysis.
--
CrawfordCurrie - 30 Apr 2008
Dear Crawford,
Thanks for your analysis and I learn so much! I try your fix and it works on 4.2, only with a little pity that there is still a little editor below!
Is it possible to make this editor really invisible? (I don't know why style="display:none" does not work!)
BTW, I find another bug in both 4.1.2 & 4.2
Item5598!!
--
TWiki:Main.MagicYang - 02 May 2008
You can try to wrap the (normal) textarea inside an invisible
div
.
--
TWiki:Main.ArthurClemens - 02 May 2008
Or simply use
<input type="hidden" id="topic" name="text" value="%TEXT%" />
as was in the 4.1.2 templates.
--
TWiki:Main.CrawfordCurrie - 02 May 2008
I like simpleness...
--
TWiki:Main.ArthurClemens - 02 May 2008
With
<input type="hidden" id="topic" name="text" value="%TEXT%" />
tinymce does create a wysiwyg editor.
I have put a hidden div around it for now as I cannot see how to prevent TMCE to not create the wysiwyg editor for a hidden field.
Perhaps Crawford can shed a light on this.
--
TWiki:Main.ArthurClemens - 02 May 2008
It's because we changed Tiny MCE to use the name of the from element
text
to instantiate the editor (
elements : "text"
in %TINYMCEPLUGIN_INIT% ). It doesn't matter that it's a type="hidden", it still goes ahead and replaces that form element. The
documentation claims that
elements
is a list of IDs, but it appears it works off element names and not IDs.
After a bit of experimentation I've concluded that the best approach is to use
mode:"textareas",editor_selector:"twikiTextarea"
instead. This has a number of advantages:
- we can use the
text
parameter without Tiny MCE camping where it isn't wanted,
-
twikiTextarea
is a class that is only applied to the main edit area,
- in the future if we want WYSIWYG in form fields, all we have to do is change it to
edit_selector:"(twikiTextarea|twikiEditFormTextAreaField)"
Can you see any reason not to do this?
--
CrawfordCurrie - 03 May 2008
That seems the right approach. But I am wary of the extra css class
twikiEditFormTextAreaField
.
--
TWiki:Main.ArthurClemens - 03 May 2008
twikiEditFormTextAreaField
is one of your classes, and we'd only use it if we added the code to support WYSIWYG of form field entries (something that would be trivial to do, but no-one has asked me for yet)
I'll go ahead with the change.
Done. You could get rid of the invisible div, but I guess it doesn't do any harm.
--
TWiki:Main.CrawfordCurrie - 04 May 2008