Skip to content

Commit

Permalink
Only load front-end form validation if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopeek committed Oct 21, 2021
1 parent 9effecc commit 061c263
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
7 changes: 7 additions & 0 deletions _build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12567,6 +12567,13 @@
"area": "FormBlocks - Settings",
"value": ""
},
{
"key": "frontend_validation",
"namespace": "formblocks",
"type": "combo-boolean",
"area": "FormBlocks - Settings",
"value": "1"
},
{
"key": "formsource",
"namespace": "formblocks",
Expand Down
6 changes: 6 additions & 0 deletions _build/src/00_electrons/e_formblocks/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"type": "textfield",
"area": "FormBlocks - Settings",
"value": ""
},{
"key": "frontend_validation",
"namespace": "formblocks",
"type": "combo-boolean",
"area": "FormBlocks - Settings",
"value": "1"
},{
"key": "formsource",
"namespace": "formblocks",
Expand Down
1 change: 1 addition & 0 deletions core/components/romanesco/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Released on ...

New features:
- Add front-end validation to FormBlocks
- Add option to use Recaptcha v3 in forms
- Add ContentBlock with Table of Contents menu
- Add output modifier for pThumb to optimize image and generate WebP version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$assetsPathVendor = $modx->getOption('romanesco.semantic_vendor_path', $scriptProperties, '');
$assetsPathDist = $modx->getOption('romanesco.semantic_dist_path', $scriptProperties, '');
$uploadFile = $modx->getOption('uploadFile', $scriptProperties, 0);
$validationTpl = $modx->getOption('validationTpl', $scriptProperties, 'fbValidation');

// Load strings to insert in asset paths when cache busting is enabled
$cacheBusterCSS = $romanesco->getCacheBustingString('CSS');
Expand All @@ -45,6 +46,11 @@
$modx->regClientHTMLBlock('<script defer src="' . $assetsPathJS . '/fileupload.min' . $cacheBusterJS . '.js"></script>');
}

// Load front-end validation, if enabled
if ($modx->getOption('formblocks.frontend_validation', $scriptProperties, '')) {
$modx->regClientHTMLBlock($modx->getChunk($validationTpl));
}

// Load custom assets, if present
// @todo: make this more dynamic
if (is_file('assets/js/formblocks.min.js')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,4 @@
</div>
</form>

[[fbLoadAssets? &uploadFile=`[[+upload_multiple]]`]]
[[loadAssets?
&component=`custom`
&inlineJS=`[[$fbValidation]]`
]]
[[!fbLoadAssets? &uploadFile=`[[+upload_multiple]]`]]

0 comments on commit 061c263

Please sign in to comment.