StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Comment form validation / filter breaks comment form ID (http://www.studiopress.com/support/showthread.php?t=118117)

PKatSP 09-20-2012 10:36 AM

Comment form validation / filter breaks comment form ID
 
I have been setting up jQuery validation for the comment form... Everything would be fine if applying a filter (as in add_filter( 'genesis_comment_form_args', 'comment_form_args' ); in the functions.php wouldn't break the form id.

this is what I have in the functions.php:
Quote:

add_filter( 'genesis_comment_form_args', 'comment_form_args' );
function comment_form_args( $args ){
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$args = array(
'fields' => array(
'author' =>
'<p class="comment-form-author">' .
'<label for="author">' . 'Name:' . '</label> ' .
'<input id="author" name="author" class="commentfield required name" type="text" value="' .
esc_attr( $commenter['comment_author'] ) .
'" size="30" tabindex="1"' .
' />' .
( $req ? '<span class="requiredspan">* Required</span>' : '' ) .
'</p><!-- #form-section-author .form-section -->',

'email' =>
'<p class="comment-form-email">' .
'<label for="email">' . 'E-mail:' . ' </label> ' .
'<input id="email" class="commentfield email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" tabindex="2"' . ' />' .
( $req ? '<span class="requiredspan">* Required, but will not be visible.</span>' : '' ) .

'</p><!-- #form-section-email .form-section -->',

'url' => '<p class="comment-form-url">' .
'<label for="url">' . 'Web:' . '</label> ' .
'<input id="url" name="url" type="text" class="commentfield" value="' . esc_attr( $commenter['comment_author_url'] ) . '" tabindex="3" />' .
'<p class="urllink">Your comment will include a publically visible link ("behind" your <br/>name) to any internet address you may specify above... </p>' .
'</p><!-- #form-section-url .form-section -->'
),

'comment_field' => '<p class="comment-form-comment">' .
'<textarea id="comment" name="comment" rows="8" tabindex="4" aria-required="true" title="Enter Message..."></textarea>' .
'</p><!-- #form-section-comment .form-section -->',

'title_reply' => 'Your Comment',
'comment_notes_before' => '',
'comment_notes_after' => '<p id="moderated">Please note that comments are moderated.</p>',
'label_submit' => 'Submit',
'cancel_reply_link' => __( 'Cancel' )
);

$args['fields']['author'] = 'author_display' ? $args['fields']['author'] : '';
$args['fields']['email'] = 'email_display' ? $args['fields']['email'] : '';
$args['fields']['url'] = 'url_display' ? $args['fields']['url'] : '';

/** Merge $args with $defaults */
return $args;
}
Works fine... HOWEVER, I have noticed (via Safari/Inspect) that if the above code is in the functions.php the first line of the form appears as this:

Quote:

<form action="http://theorderofthought.com/wp-comments-post.php" method="post" id="">
In other words the id gets "nulled" as it were — the regular id="commentform" is gone and so I can not hook my jQuery to it.

If I delete the above code from the functions.php the form returns to
Quote:

<form action="http://theorderofthought.com/wp-comments-post.php" method="post" id="commentform">
Any help to rectify this would be much appreciated! PLEASE!! :)

NicktheGeek 09-26-2012 07:52 AM

you are overriding the args completely. So you will need to specify any arguments you wish to change. IT looks like you skipped the id_form arg
http://codex.wordpress.org/Function_...e/comment_form

PKatSP 09-29-2012 01:52 AM

Thank you for your response. That is exactly what I did.

NicktheGeek 09-29-2012 07:20 AM

Everything working now?


All times are GMT -5. The time now is 01:54 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.