0

Is there a way to make differences between the normal comment form and the reply-to-form? For example, I added a set of required radiobuttons to the form which make rating by commenting happen.

Now, if someone only replies to a rating comment, these radiobuttons should not be required nor displayed in the form.

As the comment form and the reply-to-form are exactly the same, here's my question: Is there a way to check which one is currently showing? How would I disable and unset a field in the reply-form that is required in the normal comment form?

1

Easiest way to handle hiding the display is to use css. Your "reply to" form is probably displayed inside of a comment div or has some class identifying it as a comment reply.

You still might need to handle the check on the server side to make the rating field to be not required when a comment has a parent comment.

  • Yes, display:none was my first thought too but both comment forms are nested in the <div class="comment-respond" id="respond"> which means there seems to be no difference in the markup. Only the page url changes from #respond to /?replytocom=10#respond but I'm not sure if this is useful. – okiedokey Dec 3 '14 at 15:10
  • @okiedokey, use the browser developer tools to check in which div heirarchy the comment for is embedded. The two different states should result in different hierarchies obviously, and you just need to use the right heirachy when you add the display:none; rule – Mark Kaplun Dec 3 '14 at 15:21
  • sorry if I was unclear: both forms, the standard comment form and the reply-to-somebody's-comment-form are wrapped in the same class <div class="comment-respond" id="respond">. Also the hierarchy does not offer to target either one of the forms. The comments themselves do have classes which make the difference between regular comment and reply. The forms appear on the same hierarchy level, so that doesn't really help. Do you have any other ideas? – okiedokey Dec 11 '14 at 15:02

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.