[Agavi-Users] Need help in validation

0 views
Skip to first unread message

Khashayar

unread,
Sep 17, 2009, 8:18:03 AM9/17/09
to us...@lists.agavi.org
I have a problem on how to validate on a specific scenario.
let me describe this way:
I wrote the entire application with Multilingual support.
I have a News module with an AddAction inside it, so the user can add an original News content
and if he/she likes, can add translations for that news (based on locales added to translation.xml)
to add a translation, user should check related checkbox for that language (i.e French), and in the client side, i'll show that
part of the form to user to fill.

Here's the problem:
I need to validate translation fields only if that language checkbox, checked on the add news' form.
I tried different ways, but I couldn't find a solution.
if I wanna add validator to Add.xml, this won't work, cause i don't have the locales and which checkboxes checked.
if I wanna check this on registerWriteValidator and add validator for each sent translations' fields, i don't have access to checkboxes values yet.
if I wanna check this on validateWrite on the AddAction, the validation process has been passed and i don't have the values cause Agavi didn't pass the
unvalidated valuse to me.

Thanks in advanced.

Simon Cornelius P Umacob

unread,
Sep 17, 2009, 12:05:43 PM9/17/09
to Agavi Users Mailing List
Hi,

I encountered a similar problem before, and I was able to find a
solution because people in the IRC were kind enough to help me. =)
I'm sharing my solution:

<validator class="or" required="true">
<validator class="number" required="false"
provides="foobar">
<argument>mycheckbox</argument>
</validator>

<validator class="set" required="false">
<ae:parameter
name="export">mycheckbox</ae:parameter>
<ae:parameter name="value">0</ae:parameter>
</validator>
</validator>

<validator class="MyValidator" depends="foobar">
<arguments>
<argument>sometextbox</argument>
</arguments>
<errors>
<error>Somethingsomething already
exists.</error>
</errors>
</validator>

YMMV...

Regards,

[ simon.cpu ]

> _______________________________________________
> users mailing list
> us...@lists.agavi.org
> http://lists.agavi.org/mailman/listinfo/users
>
>

_______________________________________________
users mailing list
us...@lists.agavi.org
http://lists.agavi.org/mailman/listinfo/users

Reply all
Reply to author
Forward
0 new messages