/** * @param array $structure * @return ContainerInterface */ public function modify(array $structure) { if (TRUE === isset($structure['options']) && TRUE === is_array($structure['options'])) { foreach ($structure['options'] as $name => $value) { $this->setOption($name, $value); } unset($structure['options']); } if (TRUE === isset($structure['sheets'])) { foreach ((array) $structure['sheets'] as $index => $sheetData) { $sheetName = TRUE === isset($sheetData['name']) ? $sheetData['name'] : $index; // check if field already exists - if it does, modify it. If it does not, create it. if (TRUE === $this->has($sheetName)) { $sheet = $this->get($sheetName); } else { $sheet = $this->createContainer('Sheet', $sheetName); } $sheet->modify($sheetData); } } return parent::modify($structure); }
/** * @param array $settings * @return Form */ public static function create(array $settings = array()) { $form = parent::create($settings); if (TRUE === isset($settings['sheets'])) { foreach ($settings['sheets'] as $sheetName => $sheetSettings) { if (FALSE === isset($sheetSettings['name'])) { $sheetSettings['name'] = $sheetName; } $sheet = Form\Container\Sheet::create($sheetSettings); $form->add($sheet); } } return $form; }