cancel
Showing results for 
Search instead for 
Did you mean: 

List constraint with key and value

mick73
Champ in-the-making
Champ in-the-making
Hi everyone, I'm pretty new to Alfresco.
I'm using Alfresco Community Edition - latest version.

I need to define a list constraint in my custom model where the list have displayed values and key values.
Something like HTML "Select", where you can define

<option value="key">displayedValue</option>


The only constraint that I see available is:


<list>
  <value>abc</value>
  <value>def</value>
  …
</list>


with no possibilities to use a "key" different from "value".

Of course I need also that when I save, I save the key, not the displayedname!

Any help?
Thanks in advance,
Mick.
2 REPLIES 2

romschn
Star Collaborator
Star Collaborator
While defining your content model, you can have the constraint list which holds the values you want to show in the dropdown as example below.

         
 <constraint name="prefix:dropDownList" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>abc</value>
               <value>def</value>
               <value>xyz</value>            
            </list>
         </parameter>
       </constraint>

You should have a content type and define properties you want for that content type.
<type name="prefix:mytype">
              <property name="prefix:propHoldingValueFromDropDown">
               <title>My property</title>
               <type>d:text</type>
               <default>abc</default>
               <constraints>
                                 <constraint ref="prefix:dropDownList"/>
                                </constraints>
            </property>
</type>

This way you will be able to have your constraint specific values in your property.

sanzoghenzo
Confirmed Champ
Confirmed Champ

Sorry for necroposting, but I have the exact same issue and the only user that answered didn't understand the question.

Are there any updates on this topic? I'm using the latest community version of Alfresco.

To further explain, I would like to use a custom property that validates with a list, storing a key in the metadata but visualizing a description of that key (i.e. GEN=general, PMG=project management, etc).

Thanks in advance for the attention.