The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
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"); 
to:
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}\">"
with:
PHP Code:
    $resource_type $resource_info["resource_type"];
    if(
$resource_type == 'js') {
      
$link "<script type=\"text/javascript\" src=\"$g_root_url/modules/form_builder/global/form_resources/js.php?resource_id=$resource_id&nocache=$now{$query_str}\"></script>";
    } else {
      
$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}\">";
    } 

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.