cancel
Showing results for 
Search instead for 
Did you mean: 

Specify a default value in create-content form

larsg_
Champ in-the-making
Champ in-the-making
Hello,

is there any possibility (by configuration or something else) to fill a field of a create-content form with a default value?

What I already got:
<ul>
<li>The content model defines a specialisation of cm:folder (lets say new:folder). It adds two new integer properties (newSmiley Tongueroperty1 and newSmiley Tongueroperty2).
<li>The create-content menu contains a new item for creating a new:folder. When clicking on it a popup for gathering the object data is displayed; esp. a field for newSmiley Tongueroperty1 and newSmiley Tongueroperty2. When confirming a new:folder object is created and stored.
</ul>

What I like to archive:
<ol>
<li>Define a CONSTANT default value for the field for newSmiley Tongueroperty1. The content model defines a list-of-values constraint for that property. I like to define the second value a default.
<li>Define a default value which is DYNAMICALLY. In my case the parent of the created new:folder object is a new:folder object itself; the default value shall be the incremented value of newSmiley Tongueroperty2 of the parent.
</ol>

Greeting a lot of thanks in advance!
Lars
1 REPLY 1

larsg_
Champ in-the-making
Champ in-the-making
I found a solution for the 1st point:

A default value can be defined in the content model. Just add a default element to a property block:


<property name="new:property1">
  <title>1st new property</title>
  <type>d:int</type>
  <mandatory>true</mandatory>
  <default>22</default>
  <constraints>
    <constraint type="LIST">
      <parameter name="allowedValues">
        <list>
          <value>11</value>
          <value>22</value>
          <value>33</value>
        </list>
      </parameter>
    </constraint>
  </constraints>
</property>


Still searching for dynamic default values…