2008年9月25日星期四

Re: [fw-mvc] Zend_Dojo Editor (next)

The current version of the Editor in trunk seems to have some probs.
Editor values do appear to submit with the form correctly. If there's
a validation error, the Editor doesn't show its value again.

Eddie


On Sep 25, 2008, at 11:24 AM, Zladivliba Voskuy wrote:

> Thank you for your reply. I'm following your recommendations and I'm
> using the trunk editor, not the one on your blog.
>
> I investigated this a little more and it seems the form can't
> validate : here's what I have :
>
> $form = new TmpPostForm();
> $formData = $this->_request->getPost();
>
> if(!$form->isValid($formData))
> {
> echo "<br>Content : " . $form->getValue('content');
> echo "<br>title : " . $form->getValue('title');
> echo "<br><br>";
> }
> else
> echo "not valid form";
>
> $this->view->form = $form;
>
> I always get "not valid form", what is strange considering the fact
> that I reduced the Editor element to a minimum :
>
>
> // new class with dojo
> class TmpPostForm extends Zend_Dojo_Form
> {
> public function init()
> {
> // Dojo-enable the form:
> Zend_Dojo::enableForm($this);
> $this->setName('Registration form');
>
> $this->setAction('/petmanager/edit')
> ->setMethod('post');
>
> // TITLE
> $this->addElement(
> 'TextBox',
> 'title',
> array(
> 'value' => '',
> 'label' => 'Title : ',
> 'trim' => true,
> 'required' => true,
> 'invalidMessage' => 'Please add a title',
> 'validators' => array(
> array('StringLength',
> false, 4)
> )
> )
> );
>
> // POST CONTENT
> $this->addElement(
> 'editor',
> 'content'
> );
>
>
> // POST DATE
> $this->addElement(
> 'DateTextBox',
> 'date',
> array(
> 'value' => '',
> 'label' => 'Post date',
> 'required' => true,
> )
> );
>
> // THE POST ID (IF A POST IS EDITED)
> $this->addElement(
> 'Hidden',
> 'id',
> array(
> 'value' => ''
> )
> );
>
> $this->addElement(
> 'SubmitButton',
> 'send',
> array(
> 'required' => false,
> 'ignore' => true,
> 'label' => 'Send live',
> )
> );
> }
> }
>
>
>
>
>
> > Date: Thu, 25 Sep 2008 10:02:41 -0400
> > From: matthew@zend.com
> > To: fw-mvc@lists.zend.com
> > Subject: Re: [fw-mvc] Zend_Dojo Editor (next)
> >
> > -- Zladivliba Voskuy <nospampam@hotmail.fr> wrote
> > (on Thursday, 25 September 2008, 11:31 AM +0200):
> > > I have a problem with the dojo editor, how is it possible to get
> the input of
> > > the dojo editor ?
> >
> > Are you using the Editor from trunk or from my blog? It makes a
> > difference -- the one from trunk is more recent and fully tested.
> >
> > I've populated and pulled content from it just fine on my end; the
> only
> > thing I can think of is that you weren't using the Dojo form
> decorator
> > for your form -- which would mean that the onsubmit event that
> populates
> > the hidden editor element would not trigger.
> >
> >
> > > Here's my code element :
> > >
> > > $this->addElement(
> > > 'editor',
> > > 'content',
> > > array(
> > > 'editActionInterval' => 2,
> > > 'focusOnLoad' => true,
> > > 'height' => '250px',
> > > 'styleSheets' => array('/js/custom/editor.css'),
> > > ));
> > >
> > >
> > > I build my form and tried to access the elements :
> > > echo "Content : " . $form->getValue('content');
> > > echo "title : " . $form->getValue('title');
> > >
> > > I have something for the title but nothing for the editor's
> content.
> > >
> > > I checked the html :
> > > <input id="content" name="content" value="" type="hidden">
> > > <textarea id="content-Editor" name="content[Editor]"
> type="text"></textarea>
> > >
> > > So I changed 'content' to 'content[Editor]' but I got nothing.
> >
> > Not necessary -- the Editor view helper actually attaches an event
> to
> > the form's onsubmit hook that then populates the hidden element
> with the
> > content of the Editor. (If you look in Firebug, the <textarea>
> actually
> > disappears when the Editor dijit is created, which is why this is
> > necessary.)
> >
> > > One other thing, when using the form->validation, if one element
> does't
> > > validate, the content of the form is not redisplayed when using
> > >
> > > if(!$form->isValid($formData) )
> > > $form->populate($formData);
> >
> > You don't need to populate() the form after calling isValid() -
> > isValid() does that for you.
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect | matthew@zend.com
> > Zend Framework | http://framework.zend.com/
>
> Discutez gratuitement avec vos amis en vidéo ! Téléchargez
> Messenger, c'est gratuit !

没有评论: