Can't customize personalized error rendering in symfony 1.4

I am trying to set up error rendering in my form according to this example .

Here is my code:

if ($this['message']->hasError()) {
  $error_msg = '<ul>';
  foreach ($this['message']->getError() as $error) $error_msg .= "<li>$error</li>";
  $error_msg .= '</ul>';
}

return $error_msg;

      

but when $this['message']

has an error, this code returns '<ul></ul>'

, so it foreach ($this['message']->getError() as $error)

doesn't seem to call iterations

$this['message']->getError()

returns an object sfValidatorError

- maybe something changed in symfony 1.4 and it no longer iterates ...

At first I thought that all the magic in this example was due to the fact that the object is being put into $error

iteration implements __toString (), but it seems that no iterations happen at all ...

+2


a source to share


1 answer


you should have a $ form variable that contains the form to display and the code should be $ form ['message'] → hasError () and $ form ['message'] → getError () where "message" is the widget in your form. Don't use $ this as it doesn't contain a form in this context.



+2


a source







All Articles