Posts: 7
Threads: 4
Joined: Apr 2014
Reputation:
0
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?
Posts: 4
Threads: 1
Joined: Mar 2015
Reputation:
0
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.
Posts: 4
Threads: 1
Joined: Mar 2015
Reputation:
0
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:
<?php
header("Content-Type: text/css");
to:
PHP Code:
<?php
header("Content-Type: text/javascript");
Make a backup copy of file:
\modules\form_builder\global\code\generator.php
Replace line 260:
PHP Code:
<?php
$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}\">";