Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSelect and MultiSelect fields Group Fix #702
Open
Comments
apmuthu
added a commit
to apmuthu/formtools3
that referenced
this issue
May 2, 2020
formtools/core#702 formtools/core#699 For existing installs: UPDATE `ft_field_types` SET `edit_field_smarty_markup` = '{if $contents == \"\"}\n <div class=\"cf_field_comments\">\n {$LANG.phrase_not_assigned_to_option_list}\n </div>\n{else}\n <select name=\"{$NAME}\">\n {foreach from=$contents.options item=curr_group_info name=group}\n {assign var=group_info value=$curr_group_info.group_info}\n {assign var=options value=$curr_group_info.options}\n {if array_key_exists(\"group_name\", $group_info) && !empty($group_info[\"group_name\"])}\n <optgroup label=\"{$group_info.group_name|escape}\">\n {/if}\n {foreach from=$options item=option name=row}\n <option value=\"{$option.option_value}\"\n {if $VALUE == $option.option_value}selected{/if}>{$option.option_name}</option>\n {/foreach}\n {if array_key_exists(\"group_name\", $group_info) && !empty($group_info[\"group_name\"])}\n </optgroup>\n {/if}\n {/foreach}\n </select>\n{/if}\n{if $comments}\n <div class=\"cf_field_comments\">{$comments}</div>\n{/if}' WHERE `field_type_id` = '4'; UPDATE `ft_field_types` SET `edit_field_smarty_markup` = '{if $contents == \"\"}\n <div class=\"cf_field_comments\">{$LANG.phrase_not_assigned_to_option_list}</div>\n{else}\n {assign var=vals value=\"`$g_multi_val_delimiter`\"|explode:$VALUE}\n <select name=\"{$NAME}[]\" multiple size=\"{if $num_rows}{$num_rows}{else}5{/if}\">\n {foreach from=$contents.options item=curr_group_info name=group}\n {assign var=group_info value=$curr_group_info.group_info}\n {assign var=options value=$curr_group_info.options}\n {if array_key_exists(\"group_name\", $group_info) && !empty($group_info[\"group_name\"])}\n <optgroup label=\"{$group_info.group_name|escape}\">\n {/if}\n {foreach from=$options item=option name=row}\n <option value=\"{$option.option_value}\" {if $option.option_value|in_array:$vals}selected{/if}>{$option.option_name}</option>\n {/foreach}\n {if array_key_exists(\"group_name\", $group_info) && !empty($group_info[\"group_name\"])}\n </optgroup>\n {/if}\n {/foreach}\n </select>\n{/if}\n\n{if $comments}\n <div class=\"cf_field_comments\">{$comments}</div>\n{/if}' WHERE `field_type_id` = '5';
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FormTools v3.0.20
The
optgroupcode is not generated as there is a typo in the variable name in the smarty template code.Smarty v2 syntax is still used in FT 3 and is available for
foreachcommand at:https://www.smarty.net/docsv2/en/language.function.foreach.tpl
However, FormTools v3 still relies on the old syntax though it now uses Smarty 3.x library.
The files at:
global\code\field_types\Dropdown.class.phpglobal\code\field_types\MultiSelect.class.phpshould have the variable
$group_info["name"]replaced with$group_info["group_name"].These files were used in FormTools v2 but are still there for maybe compatibility reasons of some modules. They are now superseded by having the templates stored in the database table
field_types.Consequently, the following sql statements need to be executed for existing installs to effect the above variable replacement (suitably edited for your table prefix):
This enables the use of grouped selects and multi selects.
For new installs, the installer sql may need to be changed accordingly unless the information is sucked into the table from the above files.