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: Fixed
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

Comments
avatar
Date: 2018-10-05 08:44
Posted By: Mich-adg (Mich)

Hi,
i had the same problem with a Lise Instance and setting an image field to
'required' and it caused the same JS bug !
Desactivating the 'required' filed resolve the bug... !
      
avatar
Date: 2018-12-08 17:29
Posted By: matt pitt (mattyc)

I am also facing this editing with MicroTiny requires permissive_smarty=1 and I
tried to get some help from <a href
="https://uaetechnician.ae/computer-data-recovery"> data recovery dubai</a>
which is informative but I need more help regarding the bug.
      
avatar
Date: 2019-07-10 09:26
Posted By: Robert Campbell (calguy1000)

fixed in SVN
      
Updates

Updated: 2019-07-10 09:26
resolution_id: 5 => 7

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