(on Thursday, 05 February 2009, 07:47 AM -0800):
> On Wed, Feb 4, 2009 at 5:21 PM, Matthew Weier O'Phinney
> <matthew@zend.com> wrote:
> > -- Ed Lazor <edlazor@internetarchitects.biz> wrote
> > (on Wednesday, 04 February 2009, 03:54 PM -0800):
> >> Any idea why the DateTextBox only works when I add line 4?
> >>
> >> 1 $holiday = new Zend_Dojo_Form_Element_DateTextBox("holiday");
> >> 2 $holiday
> >> 3 ->setLabel('Holiday:')
> >> 4 ->setAttribs(array("dojoType"=>"dijit.form.DateTextBox"));
> >> 5
> >> 6 $this->addElements(array($holiday));
> >
> > No ideas whatsoever; I've used it fine without setting that attribute.
> >
> > How are you configuring your view object and the dojo view helper?
>
> In the bootstrap:
>
> $view = Zend_Layout::getMvcInstance()->getView();
> Zend_Dojo::enableView($view);
>
> In the controller:
>
> $form = new Zend_Dojo_Form();
> $form->addElement('DateTextBox', 'date1', array(
> 'label' => 'Choose a date:',
> 'datePattern' => 'yyy-MM-dd',
> 'validators' => array('Date'),
> 'required' => true
> ));
> $this->view->form = $form;
>
> In the view:
>
> <?php echo $this->form; ?>
>
> In the layout:
>
> <script type="text/javascript"
> src="/js/dojo-release-1.2.3-src/dojo/dojo.js"
> djConfig="parseOnLoad: true">
> </script>
>
> <script type="text/javascript">
> dojo.require("dojo.parser");
> dojo.require("dijit.form.DateTextBox");
> </script>
>
> <link rel="stylesheet" type="text/css"
> href="http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css">
I think the problem is likely due to using a CDN for the theme -- and
specifically using from a different version than your widgets. I'd
recommend using local resources for this for the time being.
Additionally, I'd recommend using the dojo() view helper to takecare of
the above items. In your bootstrap, after you Dojo-enable the view, do
the following:
Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
$view->dojo()->setLocalPath('/js/dojo-release-1.2.3-src/dojo/dojo.js')
->setDjConfigOption('parseOnLoad', true)
->addStyleSheetModule('dijit.themes.tundra');
Then, in your layout, simply echo the dojo view helper:
<?= $this->dojo() ?>
You'll notice that the configuration does not include specifying a
dojo.require statement for dijit.form.DateTextBox -- this is because
rendering the form will hint to the dojo() view helper to add this.
Let me know if the above makes a difference.
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论