5

I have some code in dexterity content type, as below:

form.fieldset(
    'transitionsLog',
    label=_(u"Transitions Log"),
    fields=['t_log']
)
form.mode(t_log='hidden')
t_log = schema.TextLine(
    title=_(u'Transitions log'),
)

In add/edit form, the field t_log hide but fieldset tab 'Transitions Log' still show at form, as above... enter image description here

I have no idea to hide "Transitions Log" tab in add/edit form,

How can I do ?

keul
  • 7,673
  • 20
  • 45
Andy
  • 213
  • 1
  • 9

2 Answers2

6

Since the fields are still rendered in hidden mode, the fieldset still exists.

If you want to completely omit the fieldset you need to omit all fields in the fieldset. This can be achieved using the omitted directive form.omitted.

form.fieldset(
    'transitionsLog',
    label=_(u"Transitions Log"),
    fields=['t_log']
)
form.omitted('t_log')  # This will also omit your fieldset
t_log = schema.TextLine(
    title=_(u'Transitions log'),
)
Mathias
  • 6,777
  • 2
  • 20
  • 32
1

I find a right way as below to omitted field in Custom Add/Edit Form:

from plone.z3cform.fieldsets.utils import remove
...
def updateWidgets(self):
    remove(self, 't_log')
    super(CustomEditForm, self).updateWidgets()
Andy
  • 213
  • 1
  • 9
  • haha you were to fast ;-) Probably you should add your comment above as a different question and das this as an answer. imho it's not the same issue. – Mathias May 20 '15 at 06:15