Translated form field name
authortflorac@dagon.home
Mon, 02 Jul 2018 23:00:09 +0200
changeset 789 7c0f6dfc6387
parent 788 88c885042341
child 790 bc6e355911d1
Translated form field name
src/pyams_content/shared/form/zmi/field.py
--- a/src/pyams_content/shared/form/zmi/field.py	Mon Jul 02 22:59:44 2018 +0200
+++ b/src/pyams_content/shared/form/zmi/field.py	Mon Jul 02 23:00:09 2018 +0200
@@ -46,6 +46,7 @@
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_utils.fanstatic import get_resource_path
 from pyams_utils.traversing import get_parent
+from pyams_utils.unicode import translate_string
 from pyams_utils.url import absolute_url
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
@@ -261,9 +262,10 @@
 def handle_new_form_field_data_extraction(event):
     """Handle new form field form data extraction"""
     container = IFormFieldContainer(event.form.context)
-    name = event.data.get('name')
+    name = translate_string(event.data.get('name'), spaces='_', keep_chars='_')
     if name in container:
         event.form.widgets.errors += (Invalid(_("Specified name is already used!")),)
+    event.data['name'] = name
 
 
 @pagelet_config(name='properties.html', context=IFormField, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)