2008年9月8日星期一

Re: [fw-mvc] Zend_Form html entities problem

Thanks Jason. Good to know it's that easy to overwrite those functions.

On Mon, Sep 8, 2008 at 3:19 PM, Jason Stames <jstames@castleaccess.com> wrote:
You can override the view escape function. All view helpers inherit their escape function from the view.

//Anywhere this will be seen by the Zend Engine before used below
//This is a dummy escape function
function noEscape($value)
{
       return $value;
}

//Place somewhere in your controller - after the view is initialized
//Set the view escape function
$this->view->setEscape('noEscape');


You can also override the default escape function for your specific select object if you still want the view to escape other output...

//Anywhere this will be seen by the Zend Engine before used below
//This is a dummy escape function
function noEscape($value)
{
       return $value;
}

//In your controller
$select->setEscape('noEscape');


If you cross a better method, please let me know.

- Jason



On 2008-09-08, at 05:36:56, Pieter wrote:

Hi everyone,

quick question; I am trying to create a dropdown box with all the country codes and names. The problem is, however, that many of these countries need html entities (as they contain umlauts, accent graves etcetera). If I use html entities like &euml; it will be converted by zend_form to &amp;uml;
Does anyone know how to circumvent this?

Sample code:

$this->addElement('select', 'country', array(
   'validators' => array(
       array(
               'regex', false, array('/^[A-Z]{2}$/',
),
),
   'label'=>'Land:',
   'required' => true,
'multiOptions' => array(
'AF'=>'Afghanistan','AL'=>'Albani&euml;','DZ'=>'Algerije','AS'=>'Amerikaanse Samoa','AD'=>'Andorra','AO'=>'Angola','AI'=>'Anguilla',
),
'decorators' => $this->elementDecorators
));

Thanks for helping!


Regards,
Pieter


没有评论: