I have defined two forms; one to add a new record and another to update
data.
I don't want to define two forms where only one fields is different
between them.
I'm trying this...
class EditFields(widgets.WidgetsList):
codice = widgets.HiddenField(name='codice')
codice_cia = widgets.TextField(name='codice_cia',label='Codice
CIA',
nome = widgets.TextField(name='nome', validator=NotEmpty)
salva =
widgets.SubmitButton(name='salva',label='',default='salva')
exit = widgets.Button(name='exit', default='esci',
label='', attrs = dict(onclick="history.back()
class AddFields(EditFields):
codice = widgets.TextField(name='codice')
but the Add Form shows only one field (codice) but Edit Form shows all
fields.
Is there a way to do that?
Thank you,
jo
I suppose somewhere in the form creation you call
fields=EditFields()
fields=AddFields()
Replace the latter with fields=EditFields()+AddFields() (WidgetsList
are lists, not compound widgets or anything magic)
and replace AddFields(EditFields) with AddFields(widgets.WidgetsList)
This should be a FAQ...
Your example is very interesting but in my case it doesn't work, because
I don't want to add some items, I want to replace some items instead.
Take a look at field 'codice', in EditFields it is a HiddenField while
in AddFields it is a TextField
....
class EditFields(widgets.WidgetsList):
codice = widgets.HiddenField(name='codice')
...
class AddFields(EditFields):
codice = widgets.TextField(name='codice')
jo
Marco Mariani ha scritto:
You are right, Marco, and it works fine. Thank you!
jo