Is there a solution to add an id to the default drupal error list items?
Currently i got this:
<div class="messages error" id="inline-messages">
<ul>
<li>Name is required.</li>
<li>Email is required.</li>
<li>Message is required.</li>
</ul>
</div>
But i would like to have the fieldname as id:
<div class="messages error" id="inline-messages">
<ul>
<li id="form-field-name">Name is r开发者_JS百科equired.</li>
<li id="form-field-email">Email is required.</li>
<li id="form-field-message">Message is required.</li>
</ul>
</div>
Plugins in use: http://drupal.org/project/inline_messages
Any suggestions?
A bit late, but maybe it will still help you or someone else looking for this, the messages are themed in theme_status_messages() but you don't have any context about them at this point. However...
Form errors are added through form_set_error(), which stores them in an static array according to the form field name, you can access that through form_get_errors().
Now, you can load these errors and then look up the error messages in that error array and use the key as the id.
精彩评论