Form field validation handler issue

cancel
Showing results for 
Search instead for 
Did you mean: 
afielden
Active Member II

Re: Form field validation handler issue

I do indeed have the config element in the XML.

Thanks for the alternate solution suggestion. Do you happen to have a link to your code please?

jpotts
Professional

Re: Form field validation handler issue

Okay, thanks for checking.

Alternative solution is to create an xml file under src/main/resources/alfresco/web-extension/site-data/extensions. Name it whatever you want, like validator.xml.

In that file you would put something like:

<modules>
        <module>
            <id>Someco Share Form Configuration</id>
            <version>1.0</version>
            <auto-deploy>true</auto-deploy>
            <configurations>

                <config>
                    <forms>
                        <dependencies>
                            <js src="/resources/someco-share/js/validator.js"/>
                        </dependencies>
                    </forms>
                </config>

                <config evaluator="node-type" condition="sc:doc">
                    <forms>
                        <form>
                            <field-visibility>
                                <show id="cm:name" />
                                <show id="cm:title" force="true" />
                                <show id="sc:someProp" />

                            </field-visibility>
                            <appearance>
                                <field id="cm:name">
                                    <control>
                                        <control-param name="maxLength">255</control-param>
                                    </control>
                                </field>
                                <field id="cm:title">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                </field>
                                <field id="sc:someProp" label-id="form.field.label.sc.someProp" description-id="form.field.description.sc.someProp" help-id="form.field.help.sc.someProp">
                                    <constraint-handlers>
                                        <constraint type="scDateValidator" message-id="constraint.scDateValidation" validation-handler="SomeCo.forms.validation.scSomePropValidatior" event="onChange"/>
                                    </constraint-handlers>
                                </field>
                            </appearance>
                        </form>

</config>

</configurations>

</module>

</modules>

</extension>

afielden
Active Member II

Re: Form field validation handler issue

That is just awesome Jeff, you are a superstar! Using this approach, with minor modifications, the Javascript validator function is now visible in the browser, and is actually being called by my form. You're very welcome to post this answer up on SO, and I'll give you the rep points.

Thanks also to Sanjay Bandhniya for contributing.

Many thanks, I've been banging my head against this brick wall for days. I'd still love to know why the original config approach wasn't working.