How can I add attributes to form tag? Below is my code but it does not add the attributes I need:

$args = array(
    'comment_notes_before' => '',
    'logged_in_as' => '',
    'class_form' => 'form-comment form-submit',
    'comment_field' =>  '<div class="medium-12 columns">
            <textarea placeholder="Message" name="message" class="form-input" rows="10" required></textarea>
            <span class="form-error">Yo, you had better fill this out, it\'s required.</span>
    'submit_button' => '<div class="medium-12 columns">
            <input type="submit" class="button button-send" value="Send">

It generates the form tag like this:

<form action="http://xxx/wp-comments-post.php" method="post" id="commentform" class="form-comment form-submit">

But I need to add data-abide novalidate:

<form action="http://xxx/wp-comments-post.php" class="form-comment form-submit" id="formComment" data-abide novalidate method="post">

Any ideas?


Use this function rather than comment_form()

function validate_comment_form(){
    echo str_replace('<form','<form attribute="value" ',ob_get_clean());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.