public function __invoke(Element $routeSelectInput) { $uploadTypeRoutesTable = $routeSelectInput->getValueOptions(); $options = array(); /* * use the url() view helper to convert each route * to an actual url on this setup */ foreach ($uploadTypeRoutesTable as $route => $type) { $url = $this->getView()->url($route); $options[$url] = $type; } /* * set the option list to tne modified version */ $routeSelectInput->setValueOptions($options); }
/** * @dataProvider getMultiElements * @group multi */ public function testRendersMultiElementsAsExpected($type, $inputType, $additionalMarkup) { if ($type === 'radio') { $element = new Element\Radio('foo'); $this->assertEquals('radio', $element->getAttribute('type')); } elseif ($type === 'multi_checkbox') { $element = new Element\MultiCheckbox('foo'); $this->assertEquals('multi_checkbox', $element->getAttribute('type')); } elseif ($type === 'select') { $element = new Element\Select('foo'); $this->assertEquals('select', $element->getAttribute('type')); } else { $element = new Element('foo'); } $element->setAttribute('type', $type); $element->setValueOptions(array('value1' => 'option', 'value2' => 'label', 'value3' => 'last')); $element->setAttribute('value', 'value2'); $markup = $this->helper->render($element); $this->assertEquals(3, substr_count($markup, '<' . $inputType), $markup); $this->assertContains($additionalMarkup, $markup); if ($type == 'select') { $this->assertRegexp('#value="value2"[^>]*?(selected="selected")#', $markup); } }