I resolved the problem in the end by realizing that the actual
form_error function is only displaying the error messages from the
request.

You can get around the disgusting non-compliant code, by running your
own function put in on of the auto load directories (e.g. myproject/
lib), which uses your own slightly different code, I changed the error
tag to a span (like what my javascript creates too) so all the class
names and DOM elements match, both server-side, and client side.

The function i created is "show_form_error" because in reality, thats
all it does. I like span's better for displaying error messages as
they give you more flexibility. Otherwise everything else is the
same....

Maybe this might be appended to the form handling for symfony in
general. I don't see what the point of having a div with bad markup,
which isn't displayed at all. -  It makes no sense at all.

Regards,
Simon

<?php

 function show_form_error($param, $options = array(), $catalogue =
'messages')
    {
      $param_for_sf = str_replace(array('[', ']'), array('{', '}'),
$param);
      $param = str_replace(array('{', '}'), array('[', ']'), $param);

      $options = _parse_attributes($options);

      $request = sfContext::getInstance()->getRequest();

      if (!isset($options['class']))
      {
        $options['class'] = sfConfig::get('sf_validation_error_class',
'form_error');
      }
      if (!isset($options['id']))
      {
        $options['id'] =
sfConfig::get('sf_validation_error_id_prefix',
'error_for_').get_id_from_name($param);
      }

      $prefix = sfConfig::get('sf_validation_error_prefix', '');
      if (isset($options['prefix']))
      {
        $prefix = $options['prefix'];
        unset($options['prefix']);
      }

      $suffix = sfConfig::get('sf_validation_error_suffix', '');
      if (isset($options['suffix']))
      {
        $suffix = $options['suffix'];
        unset($options['suffix']);
      }
      $error = $request->getError($param_for_sf, $catalogue);

      if($error){
         return content_tag('span', $prefix.$error.$suffix,
$options)."\n";
      }
    }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to