Skip to content

Commit ed7f207

Browse files
committed
Fix collective#396. Custom action scripts gets server side flagged fields in the fields dict parameter under the name_of_the_field key.
1 parent 77fbd60 commit ed7f207

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/collective/easyform/actions.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,20 @@ def getScript(self, context):
584584
script.ZPythonScript_edit(params, body)
585585
return script
586586

587-
def sanifyFields(self, form):
587+
def sanifyFields(self, form, fields):
588588
# Makes request.form fields accessible in a script
589589
#
590590
# Avoid Unauthorized exceptions since request.form is inaccesible
591591

592592
result = {}
593593
for field in form:
594594
result[field] = form[field]
595+
596+
# append in the results all serverside fields variable
597+
for field in fields:
598+
key = 'form.widgets.{}'.format(field)
599+
if key not in result:
600+
result[field] = fields[field]
595601
return result
596602

597603
def checkWarningsAndErrors(self, script):
@@ -638,7 +644,7 @@ def executeCustomScript(self, result, form, req):
638644
def onSuccess(self, fields, request):
639645
# Executes the custom script
640646
form = get_context(self)
641-
resultData = self.sanifyFields(request.form)
647+
resultData = self.sanifyFields(request.form, fields)
642648
return self.executeCustomScript(resultData, form, request)
643649

644650

0 commit comments

Comments
 (0)