function renderOptions() { $this->identifiers->setProvider('Foo', function () { return ['one' => 'uno', 'two' => 'dos', 'three' => 'tres']; }); $parameter = new Parameter('foo', new IdentifierType('Foo', new StringType())); $this->assert($this->field->render($parameter, 'two'), '<select name="foo" class="form-control">' . "\n" . '<option value="one">uno</option>' . "\n" . '<option value="two" selected="selected">dos</option>' . "\n" . '<option value="three">tres</option>' . "\n" . '</select>'); }
private function initIdentifierProviders(IdentifiersProvider $identifiers) { $identifiers->setProvider(Author::class, function () { $ids = []; foreach ($this->authors->readAll() as $author) { $ids[$author->getEmail()] = $author->getName(); } return $ids; }); $identifiers->setProvider(Post::class, function () { $ids = []; foreach ($this->posts->readAll() as $post) { $ids[$post->getId()] = $post->getTitle() . ' - ' . $post->getAuthor()->getId(); } return $ids; }); return $this; }