Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
140
Merge Requests
140
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
6e330fa7
Commit
6e330fa7
authored
May 20, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add context_method_id in FormBox so that we can switch context before rendering the target form.
parent
99963bac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
product/ERP5Form/FormBox.py
product/ERP5Form/FormBox.py
+19
-0
No files found.
product/ERP5Form/FormBox.py
View file @
6e330fa7
...
...
@@ -65,6 +65,7 @@ class FormBoxWidget(Widget.Widget):
property_names
=
Widget
.
Widget
.
property_names
+
[
'formbox_target_id'
,
\
'context_method_id'
,
\
]
# This name was changed to prevent naming collision with ProxyField
...
...
@@ -76,6 +77,14 @@ class FormBoxWidget(Widget.Widget):
default
=
""
,
required
=
0
)
context_method_id
=
fields
.
StringField
(
'context_method_id'
,
title
=
'Context method ID'
,
description
=
(
"ID of the method that returns a context for this box."
),
default
=
""
,
required
=
0
)
default
=
fields
.
StringField
(
'default'
,
title
=
'Default'
,
...
...
@@ -101,6 +110,10 @@ class FormBoxWidget(Widget.Widget):
target_id
=
field
.
get_value
(
'formbox_target_id'
)
if
target_id
not
in
(
None
,
''
):
here
=
REQUEST
[
'here'
]
context_method_id
=
field
.
get_value
(
'context_method_id'
)
if
context_method_id
:
original_here
=
here
REQUEST
[
'here'
]
=
here
=
getattr
(
here
,
context_method_id
)()
# If 'cell' is not defined, we define 'cell' just same as 'here', so
# that we can use the same formbox for both ListBox and non-ListBox
# using 'cell' parameter.
...
...
@@ -114,6 +127,9 @@ class FormBoxWidget(Widget.Widget):
(
field
.
id
,
field
.
aq_parent
.
id
))
else
:
result
=
form
(
REQUEST
=
REQUEST
,
key_prefix
=
key
)
finally
:
if
context_method_id
:
REQUEST
[
'here'
]
=
original_here
return
result
class
FormBoxEditor
:
...
...
@@ -165,6 +181,9 @@ class FormBoxValidator(Validator.Validator):
def
validate
(
self
,
field
,
key
,
REQUEST
):
# XXX hardcoded acquisition
here
=
field
.
aq_parent
.
aq_parent
context_method_id
=
field
.
get_value
(
'context_method_id'
)
if
context_method_id
:
here
=
getattr
(
here
,
context_method_id
)()
formbox_target_id
=
field
.
get_value
(
'formbox_target_id'
)
# Get current error fields
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment