cancel
Showing results for 
Search instead for 
Did you mean: 

How set a default value of a form field on a module extension surf form

4535992
Star Collaborator
Star Collaborator

here my module surf extension:

==================================================================

alfresco/web-extensions/site-data/extensions/my-module-actions-extension-modules

==================================================================

<extension>
    <modules>
        <module>
            <id>signed-as-aruba</id>
            <version>${project.version}</version>
            <auto-deploy>true</auto-deploy>
            <configurations>
                
                <config evaluator="string-compare" condition="DocumentLibrary">
                    <indicators>                       
                        <indicator id="indicator.isSigned"
                            icon="signed-doc-16.png"
                            index="100"
                            label="indicator.isSigned.label">
                            <evaluator>alfresco.evaluator.isSignable</evaluator>
                        </indicator>
                    </indicators>
                    
                    <toolbar-actions>
                          <action type="action-link" id="doclib.action.signedAsAruba" label="menu.selected-items.signedAsAruba" />
                      </toolbar-actions>

 

                </config>
                
                <config evaluator="string-compare" condition="DocLibActions">
                    <actions>

 

                        <action id="doclib.action.signedAsAruba"
                            icon="signed-doc-16.png"
                            type="javascript"
                            label="doclib.action.signedAsAruba.label">
                            <param name="function">onActionFormDialog</param>
                            <param name="itemKind">action</param>
                            <param name="itemId">signed-as-aruba</param> <!-- Repository action id = Spring Bean id -->
                            <param name="mode">create</param>
                            <param name="destination">{node.nodeRef}</param>
                            <param name="successMessage">sign.doclib.action.signed.msg.success</param>
                            <param name="failureMessage">sign.doclib.action.signed.msg.failure</param>
                            <evaluator>alfresco.evaluator.isSignable</evaluator>
                        </action>

 

                        <action id="sign.doclib.action.callWebScript"
                                icon="callws"
                                type="javascript"
                                label="sign.doclib.action.callWebScript.label">
                            <param name="active">true</param>
                            <param name="function">onActionCallWebScript</param>
                            <param name="successMessage">sign.doclib.action.callWebScript.msg.success</param>
                            <param name="failureMessage">sign.doclib.action.callWebScript.msg.failure</param>
                        </action>
                    </actions>

 

                    <actionGroups>
                        <actionGroup id="document-browse">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>
                        <actionGroup id="document-details">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>

 

                        <actionGroup id="folder-browse">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>
                    </actionGroups>
                </config>

 

                <config evaluator="string-compare" condition="DocLibCustom">
                    <dependencies>
                        <js src="components/documentlibrary/custom-doclib-actions.js" />
                    </dependencies>
                </config>

 

                <!-- ====== -->
                <!-- FORMS  -->
                <!-- ====== -->
                <config evaluator="string-compare" condition="signed-as-aruba">
                    <forms>
                        <form>
                            <field-visibility>
                                <show id="otp"/>
                                <show id="luogo"/>
                                <show id="motivo"/>
                                <show id="username"/>
                                <show id="password"/>
                            </field-visibility>
                            <appearance>
                              <field id="otp" label-id="property.form.sign.my_form_sign_firma.otp">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>    
                              <field id="luogo" label-id="property.form.sign.my_form_sign_firma.luogo">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>                                                        
                              <field id="motivo" label-id="property.form.sign.my_form_sign_firma.motivo">
                                    <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                              </field>
                              <field id="username" label-id="property.form.sign.my_form_sign_firma.username">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>
                              <field id="password" label-id="property.form.sign.my_form_sign_firma.password">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>              

                              <field id="myHiddenField" label-id="property.form.sign.my_form_sign_firma.hiddenField">
                                         <control template="/org/alfresco/components/form/controls/hidden.ftl" />

                                         <!-- HOW SET A DEFAULT VALUE ?  -->
                              </field>                      
            
                            </appearance>
                        </form>
                    </forms>
                </config>  
            </configurations>
        </module>
    </modules>
</extension>

my question are simple but i'm not found a good reference to the documentation of alfresco.

How to set a default value? I must create a custom file template (e.g. customtextField.ftl) with a specific value or can i set that on the xml config exetnsion module with some specific tag?

Greetings.

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

You cannot set a default value via a form configuration. You can only set default values on the Repository-tier either via the data model (if you are dealing with types / nodes / workflows / tasks) or a form filter (any forms, including actions which you are dealing with).

View answer in original post

1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator

You cannot set a default value via a form configuration. You can only set default values on the Repository-tier either via the data model (if you are dealing with types / nodes / workflows / tasks) or a form filter (any forms, including actions which you are dealing with).