-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Hello!
Please advise.
Is it possible to implement control over hiding fields and entire Fieldsets within a FormCollection?
Here is an example of the structure:
class AssemblyParentsOtherFormMassFieldset(Fieldset):
name = fields.CharField(
label="name",
widget=widgets.TextInput(),
required=False,
)
nickname = fields.CharField(
label="nickname",
widget=widgets.TextInput(
attrs={
'df-show': "parents_part.0.parent.parent_other.no_nickname==''",
'df-disable': "parents_part.0.parent.parent_other.no_nickname"
}
),
required=False,
)
no_nickname = fields.BooleanField(
label="Switch",
widget=widgets.CheckboxInput(),
initial=False,
required=False
)
class AssemblyParentsFormMassPart(Form):
parent_social_passport = AssemblyParentsSocialPassportFormSingleFieldset(
legend="Date parent",
hide_condition='parents_part.0.parent.parent_not_social_passport',
)
parent_other = AssemblyParentsOtherFormMassFieldset(
legend="Date parent",
show_condition='parents_part.0.parent.parent_not_social_passport',
)
parent_not_social_passport = fields.BooleanField(
label="Switch",
required=False,
)
class AssemblyParentsMassAddParentsCollection(FormCollection):
default_renderer = FormRenderer()
legend = "Date parent"
min_siblings = 1
add_label = "Add parent"
parent = AssemblyParentsFormMassPart()
class AssemblyParentsMassAddCollectionForm(FormCollection):
contest_part = AssemblyParentsContestsPart()
parents_part = AssemblyParentsMassAddParentsCollection()
In this structure, df-show, show_condition, and hide_condition only work for a single instance.
In one of the discussion threads, I found a possible solution:
def get_context(self):
context = super().get_context()
bundle_id = self.form_id.split('.')[1]
context['show_condition'] = context['show_condition'].replace("X", bundle_id)
return context
However, currently, self.form_id, show_condition, and hide_condition do not work within the Fieldset itself.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels