Jump to content

Adding custom field to comments form


gebeer
 Share

Recommended Posts

Hello,

I need to add a checkbox to the  comments form to make it GDPR compliant and I guess I'm not the only one...

Doing a search and looking at the FieldTypeComments module file it seems that the only way to add custom fields to the form is by copying the module to  site/modules and apply the changes there.

I am just wondering why the comment form is not driven by the PW form API and also why none of the methods in that module are hookable?

Would be much appreciated if you could share your approaches on handling this.  

  • Like 1
Link to comment
Share on other sites

On 6/13/2018 at 10:49 PM, gebeer said:

Doing a search and looking at the FieldTypeComments module file it seems that the only way to add custom fields to the form is by copying the module to  site/modules and apply the changes there.

Yep, that's the only way I know of to customise the comments module.

  • Like 1
Link to comment
Share on other sites

3 hours ago, bernhard said:

You could inject the checkbox via a little JavaScript that disables the form unless the checkbox is checked. It's might be an ugly hack, but it might be the best solution in your case..

This is an option only for visitors with JS enabled.
I decided to copy the module to site/modules and extend it there.

Though it would be really nice if we could extend the comments form with hooks.

Link to comment
Share on other sites

6 minutes ago, gebeer said:

This is an option only for visitors with JS enabled.

Sure, this might or might not be a problem. You could also do a str_replace to inject the checkbox in your markup on the server side. But afterall all those solutions are hacky and you are right that it would be nice to have other options  ? 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...