[html-formfu] Localize value

Carl Franks fireartist at gmail.com
Tue Sep 13 12:58:19 GMT 2011


On 13 September 2011 11:41, Stefan <catalyst at s.profanter.me> wrote:
> Hi,
>
> I’m using Catalyst with FormFu.
>
> Now I want to localize also the values. Localizing labels is already working
> with label_loc. But there is no such function for values (like value_loc).
>
>
>
> Eg: I hav a select field:
>
>
>
>     - type: Select
>
>       name: type
>
>       label_loc: type
>
>
>
> To localize the values I use the following code in my Catalyst controller:
>
>                $form->get_element({name => 'type'})->options([
>
>                               [1,$c->loc('request')],
>
>                               [2,$c->loc('booking')]
>
>                               ]);
>
>
>
> This is working, but is there a better solution??
>
>
>
> But this method istn’t working if I have multiple radio buttons:
>
>     #Breakfast
>
>     - type: Radio
>
>       name: breakfast
>
>       label_loc: breakfast
>
>     - type: Radio
>
>       name: breakfast
>
>
>
> These two buttons have the same name because they should be a group (Know
> already about Radiogroup, but Radiogroup has the strange Border and Title).
>
> How can I set the values on these two radio buttons?
>
> $form->get_all_elements({name => 'breakfast'}) is always returning an empty
> array.
>
> I want to set one to Yes and the other to No (localized).

As Octavian mentioned, there is a value_loc() variant of value(),
so if you're using Radio fields, just try using that.

For RadioGroup, its options() method does support "value_loc" keys in
hash-ref option definitions.

Carl



More information about the HTML-FormFu mailing list