authn: Generate the form default values manually.
When using colander.flatten(data) it adds colander.null for each missing form field. But this is not correct. What we want here is a dict wich contains only the keys/values from request.params that match a form field.
This commit is contained in:
parent
bb56417060
commit
0641c0e2d0
1 changed files with 4 additions and 2 deletions
|
|
@ -80,15 +80,17 @@ class AuthnPluginViewBase(object):
|
|||
View that validates and stores the plugin settings.
|
||||
"""
|
||||
schema = self.plugin.get_settings_schema()
|
||||
data = self.request.params
|
||||
|
||||
try:
|
||||
valid_data = schema.deserialize(self.request.params)
|
||||
valid_data = schema.deserialize(data)
|
||||
except colander.Invalid, e:
|
||||
# Display error message and display form again.
|
||||
self.request.session.flash(
|
||||
_('Errors exist when saving plugin settings. '
|
||||
'Please check the form inputs.'),
|
||||
queue='error')
|
||||
defaults = schema.flatten(self.request.params)
|
||||
defaults = {key: data[key] for key in data if key in schema}
|
||||
return self.settings_get(errors=e.asdict(), defaults=defaults)
|
||||
|
||||
# Store validated data.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue