Revert to using fieldmangler for adding fields

In 5.1.5 we switched to using `<$action-setfield>` instead of
`<$fieldmangler>`. The problem was that in the process we lost the
validation of field names, making it possible to create fields with
illegal names

Fixes #1186
This commit is contained in:
Jermolene
2014-12-04 09:39:14 +00:00
parent bb74be7ac1
commit 2689e2861b
2 changed files with 51 additions and 21 deletions

View File

@@ -5,9 +5,27 @@ tags: $:/tags/EditTemplate
\define config-title()
$:/config/EditTemplateFields/Visibility/$(currentField)$
\end
\define config-filter()
[[hide]] -[title{$(config-title)$}]
\end
\define new-field(name,value)
<$reveal type="nomatch" text="" default="""$name$""">
<$button>
<$action-sendmessage $message="tm-add-field" $name$="""$value$"""/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<<lingo Fields/Add/Button>>
</$button>
</$reveal>
<$reveal type="match" text="" default="""$name$""">
<$button>
<<lingo Fields/Add/Button>>
</$button>
</$reveal>
\end
<div class="tc-edit-fields">
<table class="tc-edit-fields">
<tbody>
@@ -32,6 +50,7 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
</table>
</div>
<$fieldmangler>
<div class="tc-edit-field-add">
<em class="tc-edit">
<<lingo Fields/Add/Prompt>>
@@ -43,11 +62,8 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
<$edit-text tiddler="$:/temp/newfieldvalue" tag="input" default="" placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} class="tc-edit-texteditor"/>
</span>
<span class="tc-edit-field-add-button">
<$button>
<$action-setfield $field={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<<lingo Fields/Add/Button>>
</$button>
<$macrocall $name="new-field" name={{$:/temp/newfieldname}} value={{$:/temp/newfieldvalue}}/>
</span>
</div>
</$fieldmangler>