Hi Yeah sure it's always better to create a clearer helper-solution... :) Well with your solution you'll not be able to set the other classes. I'd recommend to add another (optional) parameter:
/** * Assigns error-CSS Class to a given Field if validation has failed * * @param string $formfieldName * @param string $classes * @return string */ function setFormfieldInlineError($formfieldName,$classes='') { if (sfContext::getInstance()->getRequest()- >hasError($formfieldName)) { return 'class="formfield-inline-error '.$classes.'"'; } return 'class="'.$classes.'"'; } greets red On 16 Apr., 13:14, Daniel Haller <[EMAIL PROTECTED]> wrote: > Hi Red, > > > You could try something like > > > <?php echo input_tag('thefield', '', > > array('class'=>form_has_error('thefield')?'error':'')) ?> > > I found a similar solution for this, but I am now using a helper-Function: > > /** > * Assigns error-CSS Class to a given Field if validation has failed > * > * @param string $formfieldName > * @return string > */ > function setFormfieldInlineError($formfieldName) { > if (sfContext::getInstance()->getRequest()->hasError($formfieldName)) > { > return 'class="formfield-inline-error"'; > } > > } > > Very simple. > Maybe it's been a little late last night :-) > > Thank you, > Daniel > > > HTH > > red > > > On 16 Apr., 02:00, Daniel Haller <[EMAIL PROTECTED]> wrote: > >> Hi everybody, > > >> is it possible to assign a CSS-Class (f.e. "error") directly to an > >> input-field Tag when it fails validation? > > >> Of course you display an error message with the form_error()-Function. > >> But this function wraps the message in some markup (div's), so I can't > >> use it directly in the input-Tag... > > >> Thanks for advice, > >> Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---