SOLVED: GJ: How to validate the description field on Group save?

1 year 3 weeks ago #333286 by NFA
Hi,

Is there a way to make the GroupJive field "description" mandatory and force users to fill it with at least 50 characters?

Regards, Noa

Please Log in to join the conversation.

1 year 3 weeks ago #333295 by krileon
There's no functionality to make description mandatory at this time. If this is something critical to your site I can review adding a trigger that'll let you add custom validation with CB Auto Actions though.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: NFA

Please Log in to join the conversation.

1 year 3 weeks ago #333297 by krileon
Went ahead and improved the triggers while handling your GJ About question. The below in CB Auto Actions will let you add new validation.

Global
Triggers: gj_onBeforeCreateGroup, gj_onBeforeUpdateGroup
Type: Code
User: Self
Access: Everybody
Action
Method: PHP
Code:
if ( cbutf8_strlen( $variables['var1']->getString( 'description', '' ) ) < 50 ) {
	$variables['var1']->setError( 'Please provide a description' );
	
	return false;
}

return true;
Output
Display: return

The above will output "Please provide a description" validation error if they try to save without a description. To add client side validation you can use the below.

Global
Triggers: gj_onBeforeDisplayGroupEdit
Type: Code
User: Self
Access: Everybody
Action
Method: jQuery
Code:
$( '.gjGroupEditForm #description' ).attr( 'minlength', 50 ).addClass( 'required' );

That will add a minimum length requirement of 50 and mark the field as required.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: NFA

Please Log in to join the conversation.

1 year 3 weeks ago #333310 by NFA
Hi Kyle, thanks again for your incredibly fantastic and fast support !!!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.210 seconds

Facebook Twitter LinkedIn