示例#1
0
文件: Dijit.php 项目: rexmac/zf2
 /**
  * Set the view object
  *
  * Ensures that the view object has the dojo view helper path set.
  *
  * @param  \Zend\View\ViewEngine $view
  * @return \Zend\Dojo\Form\Element\Dijit
  */
 public function setView(View $view = null)
 {
     if (null !== $view) {
         if (false === $view->getPluginLoader('helper')->getPaths('Zend\\Dojo\\View\\Helper')) {
             $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend\\Dojo\\View\\Helper');
         }
     }
     return parent::setView($view);
 }
示例#2
0
    public function testRetrievingLabelRetrievesLabelWithTranslationAndPrefixAndSuffix()
    {
        $translate = new Translator('ArrayAdapter', array('My Label' => 'Translation'), 'en');
        $translate->setLocale('en');

        $element = new 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);
    }
示例#3
0
文件: Dijit.php 项目: alab1001101/zf2
 /**
  * Set the view object
  *
  * Ensures that the view object has the dojo view helper path set.
  *
  * @param  \Zend\View\Renderer $view
  * @return \Zend\Dojo\Form\Element\Dijit
  */
 public function setView(View $view = null)
 {
     if (null !== $view) {
         if (false === $view->broker()->isLoaded('dojo')) {
             $loader = new \Zend\Dojo\View\HelperLoader();
             $view->broker()->getClassLoader()->registerPlugins($loader);
         }
     }
     return parent::setView($view);
 }