2009年7月29日星期三

[fw-mvc] Re: [fw-general] encoding Zend_form UTF-8 to ISO...

Zend_Form uses the view from the action controller's view renderer by default.

Forgot to send to list :)

--

If you're using the new Zend_Application, you can add this line to your application.ini:

resources.view.encoding = "ISO-8859-1"

Or, you can manually set the view early in your application:

$view = new Zend_View();
$view->setEncoding("ISO-8859-1");
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view);

If you're using Zend_Form as a standalone component, you can set its view object manually:

$form->setView($view);

I hope this helps :)

--
Hector


On Wed, Jul 29, 2009 at 8:23 AM, Juan Pablo Marroni <jmarroni@gmail.com> wrote:
Hi, I have a question, How indicate to Zend_form the encoding?  I want to use encoding ISO because my app is in this charset, but the Zend_form is utf-8 currently
Greetings and thanks

I have this code:
Controller:

            $form = new Zend_Form();
            $form    ->setName()
                    ->setAction()
                    ->setMethod('post');

          $form->addElement('hidden','idRes',array(
                                'value' => $idRes
                                ));

            $form->addElement('text','Name',array(
                    'label' => 'Name:',
                    'value' => $resto[0]['Name'],
                    'decorators' => $this->decorators_left
                    ));

View:
<form id = "Name" action="<?php echo $this->formVoto->getAction(); ?>">
            <?php echo $this->formVoto->idResto; ?>
            <?php echo $this->formVoto->Name; ?>
</form>

没有评论: