MForm displays a tree of elements - if the schema permits, some of these elements
may be removed, other may have subelements added.
When it comes to removing, the task is easy - there is a removal button near the
element. Pressing this button removes the element on condition that after removing
this element the amount of these element's siblings would not be lower than the
MinOccurs property.
But with adding elements, the task is a little bit more complicated. The buttons
to add elements are kept in their elements parents. In HTML they are in the div
with BC (button container) class. It is absolutely possible to use
these buttons, however mixing adding new elements with editing the existing ones
is not favourable.
This is why in the defualt styles the div.BC selector is set to display:
none.
To display the 'add' buttons in one place, the TabButtons control can
be used.
The control works in such a way, that clicking an element on the form forces the
control to display 'add' buttons that are bound to the clicked element.
The control contains a Depth property (the default value of this property
is 2), which informs how deep should the control go in displaying parent's buttons:
- 1 - display only clicked element's buttons
- 2- display clicked element's and its parent's buttons)
- 3- display clicked element's and its parent's and grandparent's buttons)
- etc ...
Because some elements do not have associated buttons (i.e. leaf elements that cannot
have any children), setting the Depth property to 3 will not necessarily
mean that 3 button containers will be displayed. To count only non-empty button
containers, one can set the CountEmptyContainers property to false.