Re: Form Validation with multi-lingual fields ?

[email protected]
Newsgroups gmane.comp.cms.jahia.devel
Message-ID <OFCBDC1CA9.85698783-ONC12570DC.005A7C7C-C12570DC.005AE91F@commaro.com>
We continued the conversation the last time and I explained that there is 
no check at the language change. When pressing Save "validwhen" will check 
just the  current language somebody is working on.

Benjamin Papez

System Architect
***************************************************
COMMARO mobile trading systems GmbH
Lakeside B04
A-9020 Klagenfurt - Austria/Europe

phone: +43 (463) 298505-38
fax: +43 (463) 298505-22
***************************************************

Sébastien Landeau <[email protected]> wrote on 19.12.2005 
16:11:36:

> 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.2005 
16: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, 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, 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.