2008年9月8日星期一

Re: [fw-mvc] Zend_Form html entities problem

Thanks Adam! Your solution works great.

On Mon, Sep 8, 2008 at 3:14 PM, Adam Hunter <ah125i@gmail.com> wrote:
Hi,

This is because Zend_Form render's through Zend_View's helpers.  This escapes form values by default.  I use (in my controller) $this->view->setEscape('stripslashes').  This way your form values won't be converted to HTML Entities.  From inside your form class you can do $this->getView()->setEscape('stripslashes').
Hope this helps.

Adam


On Mon, Sep 8, 2008 at 8:36 AM, Pieter <ptrwrsm@gmail.com> 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


没有评论: