/** * @inheritdoc * * @param array|\Traversable $data * * @throws \Assert\AssertionFailedException */ public function prepareElement(FormInterface $form) { parent::prepareElement($form); /** @var Element\Collection $authDataElement */ $authDataElement = $this->get('authData'); /** @var AuthFieldset $authFieldset */ $authFieldset = current($authDataElement->getFieldsets()); Assertion::isInstanceOf($authFieldset, AuthFieldset::class); $authId = $authFieldset->get('id')->getValue(); $valueOptions[$authId] = ''; /** @var Element\Select $authSelect */ $authSelect = $this->get('auth'); $authSelect->setValueOptions($valueOptions); }
/** * @inheritdoc * * @param array|\Traversable $data * * @throws \Assert\AssertionFailedException */ public function prepareElement(FormInterface $form) { /** @var Select $authElement */ $authElement = $this->get('auth'); Assertion::isInstanceOf($authElement, Select::class); /** @var Element\Collection $allAuthData */ $allAuthData = $this->get('authData'); $valueOptions = []; foreach ($allAuthData->getIterator() as $elementOrFieldset) { if ($elementOrFieldset instanceof AuthFieldset) { $id = $elementOrFieldset->get('id')->getValue(); $text = $elementOrFieldset->get('description')->getValue(); $valueOptions[$id] = $text; } } $authElement->setValueOptions($valueOptions); parent::prepareElement($form); }