/** * {@inheritdoc} */ protected function layout() : Container { if ($this instanceof Group || $this instanceof Fieldset) { $this->applyContainerSize($this->container->elements); } else { $this->applySize($this); } if ($this->getGridSize()) { $container = new Container(); // label if ($this->getLabel()) { $this->getLabel()->addClass('col-sm-' . $this->getGridSize())->addClass('control-label'); $container->add($this->getLabel()); } // field if ($this instanceof Group) { $fieldWrapper = $this->getContainer(); } else { if (sizeof($this->inputGroups)) { $fieldWrapper = new HtmlContainer('<div>'); $fieldWrapper->add($inputGroupWrapper = (new HtmlContainer('<div>'))->addClass('input-group')); if (isset($this->inputGroups[true])) { foreach ($this->inputGroups[true] as $inputGroup) { $inputGroupWrapper->add($inputGroup); } } $inputGroupWrapper->add($this->getField()); if (isset($this->inputGroups[false])) { foreach ($this->inputGroups[false] as $inputGroup) { $inputGroupWrapper->add($inputGroup); } } } else { $fieldWrapper = new HtmlContainer('<div>'); $fieldWrapper->add($this->getField()); } } if ($this instanceof MultipleGroup) { $fieldWrapper->getElement()->addClass('col-sm-' . (12 - $this->getGridSize())); } else { $fieldWrapper->addClass('col-sm-' . (12 - $this->getGridSize())); } // label if (!$this->getLabel()) { $fieldWrapper->addClass('col-sm-offset-' . $this->getGridSize()); } // help wrap if ($this->helpText) { $fieldWrapper->add($this->helpText); } $container->add($fieldWrapper); return $container; } else { $container = parent::layout(); if ($this->helpText) { $container->add($this->helpText); } return $container; } }