The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.28 (Linux)
|
FormBuilder - new JS resource loading as style! - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16) +--- Thread: FormBuilder - new JS resource loading as style! (/showthread.php?tid=4729) |
FormBuilder - new JS resource loading as style! - poorya - Oct 18th, 2014 Hi, Thank you for your great work, I added a resource to one of my default template sets as JS and placed the placeholder code in the templates, in "header" one. the code is loading but as a Style not JavaScript! The "Resource Type" is "JS"! What is wrong with me? RE: FormBuilder - new JS resource loading as style! - john-m-adams - Apr 1st, 2015 Same issue. At the very least, does anyone know if this feature simply doesn't work, or are we doing something wrong? Please reply if adding a JS resource works for you at all. Thank you. RE: FormBuilder - new JS resource loading as style! - john-m-adams - Apr 1st, 2015 It appears form builder's function fb_generate_form($settings) does not check the resource type yet, and serves all resources as css. See \modules\form_builder\global\code\generator.php , beginning line 256. This bug also appears in the bug tracker: Issue #365 ยป JavaScript Form Builder Resource applied as CSS Sheet, when specified as JavaScript type For the time being, the best option is likely to upload a js file elsewhere, and hard code the script link into your template. That won't achieve what css.php does, as far as access control (It looks like it won't serve resources for a private form unless you're logged in, which is nice to know, if I find a reason for private forms). Alternately, you can live dangerously, and do this for the current version: Core 2.2.6 Formbuilder 1.0.7 Copy File: \modules\form_builder\global\form_resources\css.php to \modules\form_builder\global\form_resources\js.php In the new copy, js.php, Change line 10: PHP Code: header("Content-Type: text/css"); PHP Code: header("Content-Type: text/javascript"); Make a backup copy of file: \modules\form_builder\global\code\generator.php Replace line 260: PHP Code: $link = "<link type=\"text/css\" rel=\"stylesheet\" href=\"$g_root_url/modules/form_builder/global/form_resources/css.php?resource_id=$resource_id&nocache=$now{$query_str}\">"; PHP Code: $resource_type = $resource_info["resource_type"]; No warranty provided that this is fit for any purpose. It will likely break if form builder is updated, and the bug is not fixed in the update. These instructions may not work for, or may break future or past versions. |