On Wednesday 05 August 2009 17:59:34 shaw1ea wrote:
> I get an error message stating that the index that I pass to the edit
> function in the controller is an unexpected input field. Any one have
> any ideas what might cause this? This looks like a validation message
> in red letters. I thought that the name of the index was conflicting
> with a field name on the form so I changed the name of the index and
> still got the problem. This happens in all of my RestControllers. I
> had all of the CRUD working at one time. Then the edit functions
> stopped working. Create, read, and delete still work. It is only the
> edit (update) part that stopped working. Furthermore, if I comment
> out the @validate line directly above the edit function in the
> controller then I no longer get the error message. In the code below
> the index is 'abbreak_type_id'. This is what the error message says
> is the unexpected input field.
>
> Causes error
> @validate(create_abbreak_type_form, error_handler=new)
> @expose()
> def put(self, abbreak_type_id, *args, **kw):
> ab_break_type = DBSession.query(BreakType).get
> (abbreak_type_id)
> ab_break_type.break_type = kw['break_type']
> redirect(url('../'))
>
> No Error
> #...@validate(create_abbreak_type_form, error_handler=new)
> @expose()
> def put(self, abbreak_type_id, *args, **kw):
> ab_break_type = DBSession.query(BreakType).get
> (abbreak_type_id)
> ab_break_type.break_type = kw['break_type']
> redirect(url('../'))
Your problem is not the put-function, but instead the error_handler, that you
don't show us.
If an error_handler is present, it get's passed the *same* arguments as the
action that was supposed to take the validated data.
So
@expose(...)
def new(self, *args, **kwargs):
....
should do the trick.
Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---