Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESIDECMS-2906 Client side validation defensive when validator didnt have client side defined #1554

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions system/views/formcontrols/layouts/form.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@
</cfif>

<cfif Len( Trim( formId ) ) and Len( Trim( validationJs ))>
<cfset event.include( assetId="/js/frontend/formbuilder/" )>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little sceptical of this. We're making a dependency on form builder frontend features whereas this layout is for the general preside forms system and is used in both admin and frontend non-formbuilder forms. I feel this logic could/should go somewhere else perhaps?

<cfsavecontent variable="validationJs">
( function( $ ){
var validator = $('###formId#').validate()
, options = #validationJs#;
( function( $ ) {
if ( typeof executeWithFormBuilderDependencies !== 'undefined' ) {
executeWithFormBuilderDependencies( function( $ ) {
var validator = $( '###formId#' ).validate()
, options = #validationJs#;

validator.settings.rules = $.extend( validator.settings.rules , options.rules );
validator.settings.messages = $.extend( validator.settings.messages, options.messages );
validator.settings.rules = $.extend( validator.settings.rules , options.rules );
validator.settings.messages = $.extend( validator.settings.messages, options.messages );
} );
};
} )( #validationJsJqueryRef# );
</cfsavecontent>
<cfset event.includeInlineJs( validationJs ) />
Expand Down
Loading