/** * Set the view object * * Ensures that the view object has the jQuery view helper path set. * * @param Zend_View_Interface $view * @return ZendX_JQuery_Form_Element_UiWidget */ public function setView(Zend_View_Interface $view = null) { if (null !== $view) { if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) { $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper'); } } return parent::setView($view); }
public function testRetrievingLabelRetrievesLabelWithTranslationAndPrefixAndSuffix() { require_once 'Zend/Translate.php'; $translate = new Zend_Translate('array', array('My Label' => 'Translation'), 'en'); $translate->setLocale('en'); $element = new Zend_Form_Element('foo'); $element->setView($this->getView())->setLabel('My Label')->setTranslator($translate); $this->decorator->setElement($element)->setOptions(array('optionalPrefix' => '> ', 'optionalSuffix' => ':', 'requiredPrefix' => '! ', 'requiredSuffix' => '*:')); $label = $this->decorator->getLabel(); $this->assertEquals('> Translation:', $label); $element->setRequired(true); $label = $this->decorator->getLabel(); $this->assertEquals('! Translation*:', $label); }
/** * @group ZF-8694 */ public function testLabelIsNotTranslatedTwice() { // Init translator require_once 'Zend/Translate.php'; $translate = new Zend_Translate(array('adapter' => 'array', 'content' => array('firstLabel' => 'secondLabel', 'secondLabel' => 'thirdLabel'), 'locale' => 'en')); // Create element $element = new Zend_Form_Element('foo'); $element->setView($this->getView())->setLabel('firstLabel')->setTranslator($translate); $this->decorator->setElement($element); // Test $this->assertEquals('secondLabel', $this->decorator->getLabel()); }
/** * @group ZF-8694 */ public function testDescriptionIsNotTranslatedTwice() { // Init translator require_once 'Zend/Translate.php'; $translate = new Zend_Translate(array('adapter' => 'array', 'content' => array('firstDescription' => 'secondDescription', 'secondDescription' => 'thirdDescription'), 'locale' => 'en')); // Create element $element = new Zend_Form_Element('foo'); $element->setView($this->getView())->setDescription('firstDescription')->setTranslator($translate); $this->decorator->setElement($element); // Test $this->assertEquals('<p class="hint">secondDescription</p>', trim($this->decorator->render(''))); }
public function testRenderAppendsOnRequest() { $element = new Zend_Form_Element('foo'); $element->setView($this->getView()) ->setLabel('My Label'); $this->decorator->setElement($element) ->setOptions(array('placement' => 'APPEND')); $content = 'test content'; $test = $this->decorator->render($content); $this->assertRegexp('#' . $content . '.*?<label#s', $test); }
/** * @group ZF-6667 */ public function testRenderImplicitAppendsOnRequest() { $element = new Zend_Form_Element('foo'); $element->setView($this->getView())->setLabel('My Label'); $this->decorator->setElement($element)->setOptions(array('placement' => 'IMPLICIT_APPEND', 'separator' => ' ')); $content = 'test content'; $actual = $this->decorator->render($content); $expected = '<label class="optional">test content My Label</label>'; $this->assertEquals($expected, $actual); }