Re: Form Validation with multi-lingual fields ?

Sébastien Landeau <[email protected]>
Newsgroups gmane.comp.cms.jahia.devel
Message-ID <[email protected]>
It should, but doesn't work !

Remember I have a content with an Image and a ImageAlt field
The ImageAlt is mandatory (validwhen function) if image is setted.

I've just tested, switching language during the contribution.
For example, I blank the ImageAlt in french, switch to english and valid the
form.
The validation don't catch the missing ImageAlt for french.



2005/10/3, [email protected] <[email protected]>:
>
>
> Sébastien Landeau <[email protected]> wrote on 03.10.200516:27:35:
>
> > Does this mechanism work when in edition, the contributor switch the
> > input language by clicking of the language flags in the editing pop-up ?
> >
>
>
> Yes, it should !
>
> Benjamin Papez



Sébastien Landeau <[email protected]> wrote on 03.10.200516:27:35:

> Does this mechanism work when in edition, the contributor switch the
> input language by clicking of the language flags in the editing pop-up ?
>



The *Jahia Field Input Validation
Guide*<http://www.jahia.org/jahia/webdav/site/jahia_org/shared/documentation/template/fieldInputValidationGuide.pdf>,
which is currently linked on the Documentation page is unfortunately an
older version. You should read the corrected text in Chapter 17 of the *Jahia
4.x Template Developer
Guide*<http://www.jahia.org/jahia/webdav/site/jahia_org/shared/documentation/template/Draft_Jahia_Template_Developer_Guide_v0.31.pdf>,
which is also linked on the Documentation page.

On page 108 you can read the following:

>> The validator only accesses the getter-methods of those fields, for which
you will define validation rules. The field values should be taken from the
ContainerFacadeInterface object and for that you should use the inherited
methods getJahiaField(String) or getJahiaMultiLanguageField(String). Which
method to use *depends on the validation rule*, which should be applied.
Most of the *standard validators expect the field value as a String*, but
there are *Jahia specific multilingual validations*, which need to get
access to all language entries of a field and for those fields you should
return a JahiaMltHelper object.

If you want to apply both (standard validators and Jahia multilingual
validators) to the same field you should provide two different
getter-methods. In this special case, the getter method returning the String
must match the field name property, while for the getter method returning
the JahiaMltHelper you can choose any property name.<<

So if you use the standard "validwhen" validation rule, your bean method
should return a String, even if the field-type is SMALLTEXT and the value is
multilingual.

Just use:
     public String getImageAlt()
    {
        return getJahiaField("ImageAlt");
    }

This way your "validwhen" rule will check the value of ImageAlt for the
current language somebody is working on.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.