CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#11734] 2.2.6 (testing) cms_filepicker setting 'required' parameter to true raises js error

avatar
Created By: Ruud van der Velden (ruudvdvelden)
Date Submitted: Wed Feb 14 10:15:43 -0500 2018

Assigned To:
Version: None
CMSMS Version: 2.2.5
Severity: None
Resolution: None
State: Open
Summary:
2.2.6 (testing) cms_filepicker setting 'required' parameter to true raises js error
Detailed Description:
Found in 2.2.6 during tests. Didn't check previous versions

Note it seems that when using cms_filepicker as content block in a page template
the 'required' parameter is ignored altogether. So reproducing should NOT be
done via page template. I checked using module_custom of a News editarticle.tpl
template. Just to see it happen. Real life scenario is using it in e.g. module
LISE and adding one or more required FilePicker fields.


Example:
{cms_filepicker name=$field->nameattr type='image' required=1} 

/lib/jquery/js/jquery.cmsms_filepicker.js

starting at line 41:

if( typeof(this.options.required) == 'undefined' || !
this.options.required ) {
                var lbl = 'Clear';
if( this.options.remove_label ) lbl = this.options.remove_label;
var el = this._settings.clear =
$('<button/>').text(lbl).addClass('cmsfp cmsfp_clear');

this._settings.clear is conditionally defined (NOT if this.options.required ==
true)

starting at line 20:

_about_clear: function() {
	    var v = this.element.val();
	    if( v.length > 0 ) {
		this._settings.clear.show();
	    } else {
		this._settings.clear.hide();
	    }
	},

the _about_clear 'function' is called whether or not required==true. This will
raise an error, e.g.:

'Uncaught TypeError: Cannot read property 'hide' of undefined'

Obviously stopping js processing causing all kinds of issues (like not closing
the FilePicker popup on selection, possible subsequent FilePicker fields won't
render etc etc).


History

Updates

Updated: 2018-02-14 10:20
description: Found in 2.2.6 during tests. Didn't check previous versions Example: {cms_filepicker name=$field->nameattr type='image' required=1} /lib/jquery/js/jquery.cmsms_filepicker.js starting at line 41: if( typeof(this.options.required => Found in 2.2.6 during tests. Didn't check previous versions Note it seems that when using cms_filepicker as content block in a page template the 'required' parameter is ignored altogether. So reproducing should NOT be done via page template. I checked
resolution_id: => 5