开发者

Drupal: Add id to error list

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜