Syntax error: unrecognized tag: $fields..name

Dear Forum,

I have a strange problem after importing modules which were created by the module builder. For one of my modules, there appear to be unresolvable variables in the smarty templates generated by suiteCRM:

[XXXX] [:error] [pid XXXX] [client XXX] PHP Fatal error: Smarty error: [in cache/themes/Suite7/modules/sifa/SearchForm_basic.tpl line 155]: syntax error: unrecognized tag: $fields…name (Smarty_Compiler.class.php, line 446) in /var/www/html/suitecrm/include/Smarty/Smarty.class.php on line 1094, referer: XXX

The smarty template contains lines like this:

I know which variable is causing the problem, but unfortunately I do not know why this variable is not present. I assumed that the module builder creates them automatically. I tried to repair my suiteCRM instance and deleted all caches, but the problem is still there.

Do you have a suggestion or at least a hint how I could debug this issue. I found some posts reporting similar problems (https://community.sugarcrm.com/thread/20535). However, if possible i would like to avoid tampering with the fields_meta_data table, because I would like to have portable, self-contained modules.

Thanks you very much for your help and kind regards,
Julian

Hi,
i have no response but I will search so :

do not delete caches folder
go to cache/themes/Suite7/modules/sifa/SearchForm_basic.tpl

Look where is the problem, resolve, put somethink like “here the problem” … and see.

Then go the module and …

Maybe try another theme ?

Strange

There a 2 dot :

“{$fields…name}”

Why 2 dot ? This is the bug for me.
In this file, find/replace … with .and test …if resolve.

After, find why 2 dots ?

Hum… strange.

@julianthome I remember seeing this issue a while back. I wonder what version of SuiteCRM you are running, is it an old version?

And what version of PHP and MySQL do you have?

A small advice just to make sure: when you try a Quick Repair and Rebuild, scroll down to the bottom to see if there are mismatched vardefs, and a button to fix that. If so, press the button.

Try also a few other repairs that look relevant on the Admin / Repair menu.

Another direction is for my experiment :

  • Language file and special characters. like “éà …” can cause trouble
  • UTF-8 or …maybe too
  • if field is required or not can cause trouble too

Please check also if you have a file in you have a file in custom/Extension/modules/sifa/Ext/Vardefs.php that partially defines a field that is missing from fields_meta_data table in database.

Hi,

I hit the same problem with custom module. From all custom modules only 1 has this problem,
in:
in cache/themes/SuiteP/modules/MODULE_NAME/SearchForm_advanced.tpl
there are times where I have 2 dots.

I can not find where this originates. Any ideas?
Suite version: 7.10.27

Can you paste the contents of that file? It helps to go look for where it’s generated from.

Hi @pgr,

sorry I have not replied, a was not aware of your message.
The file itself has over 300 lines, these ones are with error:

<input type='text' name='{$fields.name_advanced.name}'
    id='{$fields.name_advanced.name}' size='30'
    maxlength='255'
    value='{$value}' title=''      accesskey='9'  >
                            </div>
        </div>
    </div>
        <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-advanced-search">
        <div class="">



            {counter assign=index}
            {math equation="left % right"
            left=$index
            right=$templateMeta.maxColumns
            assign=modVal
            }

            <div class="col-xs-12">
                                <label for='aa_razredna_contacts_3_name_advanced'>{sugar_translate label='LBL_AA_RAZREDNA_CONTACTS_3_FROM_CONTACTS_TITLE' module='AA_razredna'}</label>
                            </div>
            <div class="form-item">

<input type="text" name="{$fields.aa_razredna_contacts_3_name_advanced.name}"  class="sqsEnabled"   id="{$fields.aa_razredna_contacts_3_name_advanced.name}" size="" value="{$fields.aa_razredna_contacts_3_name_advanced.value}" title='' au$
<input type="hidden"  id="{**$fields..name**}" value="{**$fields..value**}">
<span class="id-ff multiple">
<button type="button" name="btn_{$fields.aa_razredna_contacts_3_name_advanced.name}"   title="{$APP.LBL_SELECT_BUTTON_TITLE}" class="button firstChild" value="{$APP.LBL_SELECT_BUTTON_LABEL}" onclick='open_popup("{$fields.aa_razredna_contacts_3_name_advanced.module}", 600, 400, "", true, false, {literal}{"call_back_function":"set_return","form_name":"search_form","field_to_name_array":{"id":null,"name":"aa_razredna_contacts_3_name_advanced"}}{/literal}, "single", true);'><span class="suitepicon suitepicon-action-select"></span></button><button type="button" name="btn_clr_{$fields.aa_razredna_contacts_3_name_advanced.name}"   title="{$APP.LBL_CLEAR_BUTTON_TITLE}" class="button lastChild" onclick="this.form.{$fields.aa_razredna_contacts_3_name_advanced.name}.value = ''; this.form.{**$fields..name**}.value = '';" value="{$APP.LBL_CLEAR_BUTTON_LABEL}"><span class="suitepicon suitepicon-action-clear"></span></button>
</span>

It should be coming from this file:

–> themes/SuiteP/include/SearchForm/tpls/SearchFormGenericAdvanced.tpl

In that part where it calls the Smarty sugar_field custom function, defined here:

–> Smarty/plugins/function.sugar_field.php

The bug is likely either the way the parameters are passed into that, or something inside the function. You get a double dot .. because there’s an empty string between those two dots, some variable it couldn’t reference.

Good luck

1 Like

Thank you for help @pgr

I got your solution, but How do you fix it, can you have any code or screenshot, of how to resolve them? Because It is very tough to find Where this “…” is coming from. Please send the resolution for that.

This is Error
Fatal error: Smarty error: [in cache/themes/SuiteP/modules/Tasks/EditView.tpl line 63]: syntax error: unrecognized tag 'main' (Smarty_Compiler.class.php, line 584) in C:\wamp64\www\simplecrm_v268\vendor\smarty\smarty\libs\Smarty.class.php on line 1099

@Pshende I think this is already solved.

What is your PHP version, and your SuiteCRM version?

PHP 8.2 and SuiteCRM 7.14.1

That’s strange because this is a 2020 bug, I haven’t heard anybody complaining about this recently

What should we do now? Do you have any solution?

If you delete your cached tpl file, it should get recreated automatically. Try that, to see if the same error appears again.

Other than that, my answer above suggests a couple of places to look, you can hook up a debugger and look into that. But if you don’t know how to do that, it’s not something I can briefly instruct you here…

Actually, we have done everything, Like clearing cache and debugging data and all, We just upgraded PHP8.2 from PHP 8, and our Smarty version is 2. Now problem is When we set up the instance on Local and on the error reporting at that time this error comes in Listview and EditView layout both, I think if we have a solution to that, then overall all the problems will be sorted. We don’t change the Smarty Version so please don’t suggest that.

function set_{$fields..name}_values(form) {ldelim} if(form.{$fields..name}_flag.checked) {ldelim} form.{$fields..name}_flag.value=1; form.{$fields..name}.value=""; form.{$fields..name}.readOnly=true; {rdelim} else {ldelim} form.{$fields..name}_flag.value=0; form.{$fields..name}.readOnly=false; {rde

Sometimes when I get in trouble with Smarty I try to debug the actual compiled templates.

So

  1. To clear the mess, delete the entire contents of cache\smarty\templates_c
  2. Visit the edit view you want, a new file should be generated there with a weird name like %%62^62E^62E293EC%%EditView.tpl.php
  3. That file is full of ugly PHP code, but you can set breakpoints on it, so you can examine how it is getting generated. You can also use the IDE to climb up the stack and examine the functions providing the data into the template (with assign commands), that is often what needs to be fixed.

Good luck with your debugging!