cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic rendering of fields in a form

fop6316
Champ in-the-making
Champ in-the-making
Hi all,

My question is more or less in the title, I added a new data type in my data model.

<type name="moi:montype">
  <title>titre type</title>
  <parent>cm:content</parent>
  <mandatory-aspects>
    <aspect>moi:monaspect</aspect>
  </mandatory-aspects>
</type>

This one uses a new aspect in which I added a new field

<aspect name="moi:monaspect">
  <title>titre aspect</title>
  <properties>
    <property name="moi:monchamp">
      <type>d:text</type>
      <mandatory>false</mandatory>
    </property>
    …
  </properties>
</aspect>

I then displayed this new field in a Share form by editing the file share-config-custom.xml.

<config evaluator="node-type" condition="moi:montype">
  <forms>
    <form>
      <field-visibility>
        <show id="moi:monchamp"/>
        …
      </field-visibility>
      <appearance>
        <field id="moi:monchamp" label="Champ texte" />
        …
      </appearance>
    </form>
  </forms>
</config>

Till then, I could test my changes and the new field displays well.
But I would like to go further, and condition for example the display of the field depending on the logged in user's group.
If the logged in user is part of the "priviledged group", then the field is displayed, otherwise it will not, or only in read only mode.

Do you think we can do this ? And how ?
I looked at documentation, but can't find my happiness.
I don't ask for the full solution, but for tips to follow.

Thank you for your help.
1 REPLY 1

anhua-jian
Champ in-the-making
Champ in-the-making
I have tried similar customization with overriding the class org.alfresco.repo.forms.processor.AbstractFilter and org.alfresco.web.scripts.forms.FormUIGet.

You can control the visibility of the form fields in subclass of AbstractFilter. And the subclass of FormUIGet allow you to apply dynamic control to the form field.