So you need a custom FormProcessor, like:
You need to override the creation of a node:
protected NodeRef createNode(TypeDefinition typeDef, FormData data) { ...
Take the code from TypeFormProcessor and change the Association saved to ContentModel.ASSOC_SUBCATEGORIES approx. line 107.
Then you must configure you bean in the Repo context (some loaded
*-context.xml file), see alfrescos in form-services-context.xml
<bean id="categoryTypeFormProcessor" class="com.redpill_linpro.alfresco.noark5.repo.forms.processor.node.CategoryFormProcessor"
parent="typeFormProcessor">
<property name="filterRegistry" ref="typeFilterRegistry" />
<property name="matchPattern">
<value>category-type</value>
</property>
</bean>
NB! the code (class file for the new FormProcessor) must be in the WEB-INF (not share), because of class-loading dependencies.
No you can load a form, example javascript snipplet here with a configured destination.
{
itemKind: "category-type",
itemId: "cm:category",
destination: destination,
mode: "create",
submitType: "json",
formId: "doclib-common"
});
// Using Forms Service, so always create new instance
var createFolder = new Alfresco.module.SimpleDialog(this.id + "-createCategory");
createFolder.setOptions(
{
width: "33em",
templateUrl: templateUrl,
...
The itemKind variable trickers the formprocessor! type->TypeFormProcessor, category-type -> CategoryTypeFormProcessor, which I configured in the bean ...
This works for form type 'create' and sub-categories ... I will have to investigate more ... but it is nice to be able to reuse the form-framework/knowledge for categories instead of rolling your own ... this also supports custom categories, children / inherited types of cm:category.
No comments:
Post a Comment