[Solar-talk] Localize Forms / Filters

Jeff Surgeson solar at 3hex.com
Wed Jan 2 07:26:05 CST 2008


Hi Tobias,

I am not the most qualified on the list to offer help but I am sure one of the 
other guys will jump in if I am wrong.

> i try to localize my forms. the setup looks like this:
> How can i localize form and filter feedback like INVALID_NUMERIC,
> FAILURE_FORM, SUCCESS_FORM, ...?
>
> Is it possible to define this in $form->setElement() somehow?

This is how I would do it...

$form = Solar::factory('Solar_Form');

$form->setElements('postcode'    => array(
        'type'          	=> 'text',
        'label'         	=> $this->locale('LABEL_POSTCODE'),
        'attribs'       	=> array('size' => '40'),
        'require'       	=> true,
        'filters'       	=> array(
		'sanitizeTrim',
		array('validateRangeLength', 5,5),
                'validateNumeric',
        ),
	'descr' 		=> $this->locale('DESCR_POSTCODE'),
        'invalid'       	=> array(
            $this->locale('INVALID_NUMERIC'),
            $this->locale('INVALID_POSTCODE'),
        ));

My locale en_US.php is in Vendor_App_Base_Locale and the above form code is in 
Vendor_App_Example

Hope that helps

-- 
...........::::::...........
Jeff Surgeson / South Africa


More information about the Solar-talk mailing list