21286 Posts in 5733 Topics by 2602 members
| Go to End | Next > | |
| Author | Topic: | 1636 Views |
-
Page Comments Required Fields / Validator?

5 December 2010 at 8:38pm
How would I ad required filed to my page comments? It seems like I can submit a comment with no data in any of the fields, and I would like to be able to require a comment and name in the very least.
Thank you!
-
Re: Page Comments Required Fields / Validator?

6 December 2010 at 9:23am
Anyone know about this or has done this before? I'd really like to be able to require a comment and a name for submission. I've also added an email field to the comment form, so maybe require that too....but at least a comment and a name!
Thank you
-
Re: Page Comments Required Fields / Validator?

6 December 2010 at 8:07pm
The only validation is via javascript, this is fixed in the next alpha preview of comments (still in testing) but if you want to add validation:
mysite/_config
Object::add_extension('PageCommentInterface', 'RequiredComments');
mysite/code/RequiredComments.php
<?php
class RequiredComments extends Extension {function updatePageCommentForm($form) {
$form->setValidator(new RequiredFields(array('Name', 'Comment')));
}
}Commenting has basically been rewritten recently by myself (will be up on github within the week) which makes it much easier to extend but since its a major change it'll only be available for the next major release of SS.
-
Re: Page Comments Required Fields / Validator?

6 December 2010 at 8:30pm Last edited: 6 December 2010 8:31pm
Excellent! Thank you for the help, that looks easy.
Wow, a new version of comments? Will that change how things are extended? I'm fairly new to SilverStripe but LOVING it, this is such an awesome CMS. Anyway I just went through this tutorial to add an e-mail field to the comments, but if there will be a new version of comments that will change how things are extended maybe I should wait for that? Sorry if this sounds like a really dumb question, but when you say it will be on github within the week, does that mean we could grab it from there and integrate it into our current version of the CMS, or must we wait for the next version?
-
Re: Page Comments Required Fields / Validator?

15 December 2010 at 12:20pm
Hi Will,
Sorry to bother you with this, but I can't seem to get the validation to work. I've looked at everything, checked it word for word to the code, and I can still submit completely blank comments. I even disabled my captcha in case there was some sort of funny conflict that I would have no idea about. I am ready to jump off a bridge, do you think I am missing anything? I am using v2.4.3, thanks....
-
Re: Page Comments Required Fields / Validator?

17 December 2010 at 10:15am Last edited: 17 December 2010 10:15am
Hi!
Can anyone comment on what I might be doing wrong in getting validation to work on page comments? I can't seem to get this code to work. Is anyone validating their page comment fields with this method or a different method?
Thanks!
-
Re: Page Comments Required Fields / Validator?

17 December 2010 at 10:28am
Hm maybe it doesn't like being on an extension. Perhaps try alter the actual Form code in PageCommentInterface.php to add validation to the new Form(.. part (tutorial 3 covers what you need to do to add validation).
-
Re: Page Comments Required Fields / Validator?

17 December 2010 at 11:44am
OK THANKS I'll give it a go. Thanks for all you do for this community Will, SilverStripe is awesome but couldn't be much of anything to the public without the kind support of people like you :0)
| 1636 Views | ||
| Go to Top | Next > |


