use first type token as default type token, thus showing the correct fields in the create form

This commit is contained in:
Helmut Merz 2012-07-13 10:43:11 +02:00
parent 319a7b0cb9
commit 62077c5dfb
2 changed files with 7 additions and 9 deletions

View file

@ -396,6 +396,8 @@ class CreateConceptForm(CreateObjectForm):
parentType.getChildren([subtypePred])) parentType.getChildren([subtypePred]))
types = [dict(token=ConceptTypeInfo(t).token, title=t.title) types = [dict(token=ConceptTypeInfo(t).token, title=t.title)
for t in tconcepts] for t in tconcepts]
if self.defaultTypeToken is None and types:
self.defaultTypeToken = types[0]['token']
if include or include is None: if include or include is None:
return util.KeywordVocabulary(types + self.listTypes(include, ('hidden',))) return util.KeywordVocabulary(types + self.listTypes(include, ('hidden',)))
return util.KeywordVocabulary(types) return util.KeywordVocabulary(types)

View file

@ -78,7 +78,10 @@
id="dialog_form" class="dialog" id="dialog_form" class="dialog"
dojoType="dijit.form.Form" dojoType="dijit.form.Form"
tal:define="qualifier request/qualifier|view/qualifier|string:resource; tal:define="qualifier request/qualifier|view/qualifier|string:resource;
innerForm request/inner_form|view/inner_form|string:inner_form.html; innerForm
request/inner_form|view/inner_form|string:inner_form.html;
typesVocabulary python:
view.getTypesVocabulary((qualifier,));
typeToken view/typeToken; typeToken view/typeToken;
fixedType view/fixedType; fixedType view/fixedType;
langInfo view/languageInfo; langInfo view/languageInfo;
@ -104,8 +107,7 @@
'${view/virtualTargetUrl}/$innerForm')"> '${view/virtualTargetUrl}/$innerForm')">
<option value=".loops/concepts/note" <option value=".loops/concepts/note"
i18n:translate="" i18n:translate=""
tal:repeat="type python: tal:repeat="type typesVocabulary"
view.getTypesVocabulary((qualifier,))"
tal:content="type/title" tal:content="type/title"
tal:attributes="value type/token; tal:attributes="value type/token;
selected python:type.token == typeToken"> selected python:type.token == typeToken">
@ -115,12 +117,6 @@
<input type="hidden" name="form.type" <input type="hidden" name="form.type"
tal:condition="fixedType" tal:condition="fixedType"
tal:attributes="value typeToken" /> tal:attributes="value typeToken" />
<script type="text/javascript"
tal:condition="not:fixedType"
tal:content="string:replaceFieldsNode(
'form.fields', 'form.type',
'${view/virtualTargetUrl}/$innerForm')">
</script>
</th></tr></tbody> </th></tr></tbody>
<tbody><tr><td colspan="5"> <tbody><tr><td colspan="5">