* @since 100.0.2 */ class Fieldset extends AbstractElement { /** * @param Factory $factoryElement * @param CollectionFactory $factoryCollection * @param Escaper $escaper * @param array $data */ public function __construct( Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, $data = [] ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->_renderer = Form::getFieldsetRenderer(); $this->setType('fieldset'); if (isset($data['advancedSection'])) { $this->setAdvancedLabel($data['advancedSection']); } } /** * Get elements html * * @return string */ public function getElementHtml() { $html = $this->getBeforeElementHtml(); $html .= '
' . "\n"; $html .= $this->getAfterElementHtml(); return $html; } /** * Get Children element's array * * @return AbstractElement[] */ public function getChildren() { $elements = []; foreach ($this->getElements() as $element) { if ($element->getType() != 'fieldset') { $elements[] = $element; } } return $elements; } /** * Get Children element's html * * @return string */ public function getChildrenHtml() { return $this->_elementsToHtml($this->getChildren()); } /** * Get Basic elements' array * * @return AbstractElement[] */ public function getBasicChildren() { $elements = []; foreach ($this->getElements() as $element) { if (!$element->isAdvanced()) { $elements[] = $element; } } return $elements; } /** * Get Basic elements' html in sorted order * * @return string */ public function getBasicChildrenHtml() { return $this->_elementsToHtml($this->getBasicChildren()); } /** * Get Number of Basic Children * * @return int */ public function getCountBasicChildren() { return count($this->getBasicChildren()); } /** * Get Advanced elements' * * @return array */ public function getAdvancedChildren() { $elements = []; foreach ($this->getElements() as $element) { if ($element->isAdvanced()) { $elements[] = $element; } } return $elements; } /** * Get Advanced elements' html in sorted order * * @return string */ public function getAdvancedChildrenHtml() { return $this->_elementsToHtml($this->getAdvancedChildren()); } /** * Whether fieldset contains advance section * * @return bool */ public function hasAdvanced() { foreach ($this->getElements() as $element) { if ($element->isAdvanced()) { return true; } } return false; } /** * Get SubFieldset * * @return AbstractElement[] */ public function getSubFieldset() { $elements = []; foreach ($this->getElements() as $element) { if ($element->getType() == 'fieldset' && !$element->isAdvanced()) { $elements[] = $element; } } return $elements; } /** * Enter description here... * * @return string */ public function getSubFieldsetHtml() { return $this->_elementsToHtml($this->getSubFieldset()); } /** * Enter description here... * * @return string */ public function getDefaultHtml() { $html = '