How to render Form for type with aspect in Share?

cancel
Showing results for 
Search instead for 
Did you mean: 
upforsin
Senior Member

How to render Form for type with aspect in Share?

Hello,

Using `/share/service/components/form` web script we can render a form for a node or for a type. Is it posible to render a form for a type with aspects? If no, how would you implement it?

I can implement "AspectFormProcessor", but what next? How to connect it with the Alfresco Share?

It would be the best to specify properties in the request's argument and render a form with only those.

howkymike
Alfresco Developer
4 Replies
angelborroy
Alfresco Employee

Re: How to render Form for type with aspect in Share?

You can render forms for aspects in Share. A good sample is available in

https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#configur...

<config evaluator="aspect" condition="sc:webable">
    <forms>
        <form>
            <field-visibility>
                <show id="sc:published" />
                <show id="sc:isActive" />
            </field-visibility>
            <appearance>                    
                <field id="sc:published" label-id="prop.sc_published" />
                <field id="sc:isActive" label-id="prop.sc_isActive" />
            </appearance>
        </form>
    </forms>
</config>
Hyland Developer Evangelist
upforsin
Senior Member

Re: How to render Form for type with aspect in Share?

Hi @angelborroy 

thank you for the answer, I am very well aware of that configuration but I'm wondering how to render an HTML form based on i.e. type "cm:content" and aspects "sc:webable" and "cmSmiley Tonguerojectsummary". So in that example, I want to render an HTML form containing a properties from the cm:content type and properties from both "sc:webable" and "cmSmiley Tonguerojectssummary" aspects. The simpliest solution I found so far it to create a dummy node containing that type and aspects and then call `/share/service/components/form` web script with "node" itemKind.

But it seems to be a bit dirty solution.

howkymike
Alfresco Developer
angelborroy
Alfresco Employee

Re: How to render Form for type with aspect in Share?

If the node of type "cm:content" has "sc:webable" and "cmSmiley Tonguerojectsummary" aspect set, the form will include all the properties for node and types.

If you want to create a new node and show a form with these properties, you can try an approach similar to https://github.com/softwareloop/uploader-plus

Hyland Developer Evangelist
upforsin
Senior Member

Re: How to render Form for type with aspect in Share?

It is all about a new node. In the uploader-plus addon, only type can be selected (because there is no such think as PropertyFormProcessor or AspectFormProcessor, there is only NodeFormProcessor and TypeFormProcessor). I'm trying to add a functionality to select also an aspect or a property.

 

For example:

Input:

type=cm:content and aspects=[my:test, my:test2]

GET /share/service/components/form?type=cm:content&aspects=[my:test, my:test2]

Output: 

<rendered HTML form>

<form>
<input type="text" name="prop_cm_name">
<input type="text" name="prop_cm_title">
<input type="text" name="prop_cm_description">
...
<input type="text" name="prop_my_test_prop1">
<input type="text" name="prop_my_test_prop2">
<input type="text" name="prop_my_test2_prop1">
</form>

I would like to use existing Share's type and aspect form configuration.

I can of course write my own Share web script, I'm just wondering if there is an easier way. 

howkymike
Alfresco Developer