开发者

style error messages - symfony

I need to style the error messages in the newSuccess.php template. I wrote this in configure():

$this->setValidators(array(

    'id' => new sfValidatorChoice(array('choices'=>array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),

    'nome' => new sfValidatorString(array(), array('required' => 'Nome Obrigatório.')),

    'email' => new sfValidatorEmail(array(), array('invalid' => 开发者_JAVA百科'Email inválido.', 'required' => 'Email Obrigatório')),

    'contacto' => new sfValidatorString(array(), array('invalid' => 'Contacto inválido.', 'required' => 'Contacto Obrigatório')),

    'servico_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('FeasyServico'))),

    'dia'        => new sfValidatorDate(array(), array('invalid' => 'Data Inválida.', 'required' => 'Data Obrigatória.')),

    'hora'       => new sfValidatorTime(array(), array('invalid' => 'Hora Inválida', 'required' => 'Hora Obrigatória.')),
));

so the field would be required and write the following code in newSuccess.php:

<?php if ($form['nome']->hasError()) { ?>

<span class="erro">
    <br>Campo Nome Inv&Aacute;lido
</span>

<?php } ?>

The problem is that the page is showing to messages: on styled(from newSuccess.php) and one unstyled(from configure()).

I need one of this things: or delete the message from configure() and only show the message that the previous code shows, or style the created error message from configure(). hope i explained my self well.


Try this in your newSuccess.php :

<span class="erro">
 <?php echo $form['nome']->renderError(); ?>
</span>
 <?php echo $form['nome']->render() ?>


I found the answer... i just needed to put display: none; in the css class error_list. thank you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜