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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
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
Hide 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):
...
@@ -65,6 +65,7 @@ class FormBoxWidget(Widget.Widget):
property_names
=
Widget
.
Widget
.
property_names
+
[
property_names
=
Widget
.
Widget
.
property_names
+
[
'formbox_target_id'
,
\
'formbox_target_id'
,
\
'context_method_id'
,
\
]
]
# This name was changed to prevent naming collision with ProxyField
# This name was changed to prevent naming collision with ProxyField
...
@@ -76,6 +77,14 @@ class FormBoxWidget(Widget.Widget):
...
@@ -76,6 +77,14 @@ class FormBoxWidget(Widget.Widget):
default
=
""
,
default
=
""
,
required
=
0
)
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
=
fields
.
StringField
(
'default'
,
'default'
,
title
=
'Default'
,
title
=
'Default'
,
...
@@ -101,6 +110,10 @@ class FormBoxWidget(Widget.Widget):
...
@@ -101,6 +110,10 @@ class FormBoxWidget(Widget.Widget):
target_id
=
field
.
get_value
(
'formbox_target_id'
)
target_id
=
field
.
get_value
(
'formbox_target_id'
)
if
target_id
not
in
(
None
,
''
):
if
target_id
not
in
(
None
,
''
):
here
=
REQUEST
[
'here'
]
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
# 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
# that we can use the same formbox for both ListBox and non-ListBox
# using 'cell' parameter.
# using 'cell' parameter.
...
@@ -114,6 +127,9 @@ class FormBoxWidget(Widget.Widget):
...
@@ -114,6 +127,9 @@ class FormBoxWidget(Widget.Widget):
(
field
.
id
,
field
.
aq_parent
.
id
))
(
field
.
id
,
field
.
aq_parent
.
id
))
else
:
else
:
result
=
form
(
REQUEST
=
REQUEST
,
key_prefix
=
key
)
result
=
form
(
REQUEST
=
REQUEST
,
key_prefix
=
key
)
finally
:
if
context_method_id
:
REQUEST
[
'here'
]
=
original_here
return
result
return
result
class
FormBoxEditor
:
class
FormBoxEditor
:
...
@@ -165,6 +181,9 @@ class FormBoxValidator(Validator.Validator):
...
@@ -165,6 +181,9 @@ class FormBoxValidator(Validator.Validator):
def
validate
(
self
,
field
,
key
,
REQUEST
):
def
validate
(
self
,
field
,
key
,
REQUEST
):
# XXX hardcoded acquisition
# XXX hardcoded acquisition
here
=
field
.
aq_parent
.
aq_parent
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'
)
formbox_target_id
=
field
.
get_value
(
'formbox_target_id'
)
# Get current error fields
# 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