Hi
Is there any way to declare a DataGridField/Widget
in such a way that it will render a single row table only on the AddForm and will not allow appending or inserting new rows?
If I set []
as the default value for DataGridField
and disable auto_append
, allow_insert
, and allow_delete
, no rows are created. If auto_append
is enabled, more than one row may be added easily.
The only way I found is to disable auto_append
, allow_insert
, and allow_delete
in DataGridWidget
, but it only works if you pass a single row object as the default value for DataGridField
. This solution seems incorrect.
class IRowSchema(Interface):
field_set = schema.Set(
title='Field Set',
value_type=schema.Choice(
vocabulary='voc',
),
default=set(),
required=True,)
field_choice = schema.Choice(
title='Choice field',
vocabulary='voc2',
required=True,
)
class IMainSchema(model.Schema):
directives.widget(
"DGF",
DataGridWidgetFactory,
allow_insert=False,
allow_delete=False,
allow_reorder=False,
auto_append=False)
DGF = schema.List(
title='Title',
value_type=DictRow(schema=IRowSchema),
required=False,
default=[{'field_set': set(), 'field_choice': None'}]
)