| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\Traits;
- use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\RowSection;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\BaseForm;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\HalfPageSection;
- /**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 08.11.19
- * Time: 14:20
- * Class FormExtendedTrait
- */
- trait FormExtendedTrait
- {
- protected $sectionCounter = 0;
- /**
- * auto generate double section helper
- *
- * @param array $fields
- * @return $this
- * @throws \Exception
- */
- protected function generateDoubleSection($fields = [])
- {
- if(!method_exists($this, 'addSection'))
- {
- throw new \Exception('This trait can not be used in class: '.self::class);
- }
- $sections = [];
- $fieldCounter = 0;
- foreach($fields as $field)
- {
- $halfPageSection = new HalfPageSection('generated_'.$this->sectionCounter.'_'.$fieldCounter);
- $halfPageSection->addField($field);
- $sections[] = $halfPageSection;
- $fieldCounter++;
- }
- $rawSection = new RowSection('generated_row_section_'.$this->sectionCounter);
- foreach($sections as $section)
- {
- $rawSection->addSection($section);
- }
- $this->addSection($rawSection);
- $this->sectionCounter++;
- return $this;
- }
- }
|