Include raw HTML into Zend_Form

18 messages Options
Embed this post
Permalink
Gordon Ross-2

Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
Is it possible to include raw HTML into a Zend_Form ? I know you can append
& prepend HTML to a tag, but I want to include a chunck of text (with a
little HTML mark-up) in the middle of a form.

What's the best way to do this ?

Thanks,

GTG

Mike Roetgers

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
Gordon Ross schrieb:
> Is it possible to include raw HTML into a Zend_Form ? I know you can append
> & prepend HTML to a tag, but I want to include a chunck of text (with a
> little HTML mark-up) in the middle of a form.

You could use the ViewScript decorator.
Have a look at this article
(http://devzone.zend.com/article/3450-Decorators-with-Zend_Form) and
especially at the part "Example: Full Customization Using the ViewScript
Decorator".

>
> What's the best way to do this ?
>
> Thanks,
>
> GTG
>
>

Kind regards
Mike


--
Mike Rötgers
http://www.roetgers.org
oreales

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gordon Ross-2
If you want to include a "text" or "description" of an element in the middle
of a form, you can use the "description" property that all form elements
have. Theoretically, if an element has a description, this description will
be rendered (with default decorators) between the field and the errors
block.

Take a look to the Reference and API to know more.


On 18/08/2008 15:20, "Gordon Ross" <[hidden email]> wrote:

> Is it possible to include raw HTML into a Zend_Form ? I know you can append
> & prepend HTML to a tag, but I want to include a chunck of text (with a
> little HTML mark-up) in the middle of a form.
>
> What's the best way to do this ?
>
> Thanks,
>
> GTG
>


Gordon Ross-2

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gordon Ross-2
Using descriptors isn't applicable in this case.

Thanks anyway.

GTG

----- Original Message -----
From: Oscar Reales <[hidden email]>
To: [hidden email] <[hidden email]>
Sent: Tue Aug 19 08:37:48 2008
Subject: Re: [fw-mvc] Include raw HTML into Zend_Form

If you want to include a "text" or "description" of an element in the middle
of a form, you can use the "description" property that all form elements
have. Theoretically, if an element has a description, this description will
be rendered (with default decorators) between the field and the errors
block.

Take a look to the Reference and API to know more.


On 18/08/2008 15:20, "Gordon Ross" <[hidden email]> wrote:

> Is it possible to include raw HTML into a Zend_Form ? I know you can append
> & prepend HTML to a tag, but I want to include a chunck of text (with a
> little HTML mark-up) in the middle of a form.
>
> What's the best way to do this ?
>
> Thanks,
>
> GTG
>


oreales

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
Well, in that case, there is another option that I have though to implement
sometimes: extends a custom formElement that renders html. You can call this
element "text" - "rawHtml" or something similar. Create the formEelement,
the viewHelper, decorators etc.... It is much more work but once it is done,
you can uses it in any project.

Thinking on it, it will be a good feature to include in newer versions of
ZF.


On 19/08/2008 09:47, "Gordon Ross" <[hidden email]> wrote:

> Using descriptors isn't applicable in this case.
>
> Thanks anyway.
>
> GTG
>
> ----- Original Message -----
> From: Oscar Reales <[hidden email]>
> To: [hidden email] <[hidden email]>
> Sent: Tue Aug 19 08:37:48 2008
> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>
> If you want to include a "text" or "description" of an element in the middle
> of a form, you can use the "description" property that all form elements
> have. Theoretically, if an element has a description, this description will
> be rendered (with default decorators) between the field and the errors
> block.
>
> Take a look to the Reference and API to know more.
>
>
> On 18/08/2008 15:20, "Gordon Ross" <[hidden email]> wrote:
>
>> Is it possible to include raw HTML into a Zend_Form ? I know you can append
>> & prepend HTML to a tag, but I want to include a chunck of text (with a
>> little HTML mark-up) in the middle of a form.
>>
>> What's the best way to do this ?
>>
>> Thanks,
>>
>> GTG
>>
>
>


weierophinney

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gordon Ross-2
-- Gordon Ross <[hidden email]> wrote
(on Monday, 18 August 2008, 02:20 PM +0100):
> Is it possible to include raw HTML into a Zend_Form ? I know you can append
> & prepend HTML to a tag, but I want to include a chunck of text (with a
> little HTML mark-up) in the middle of a form.
>
> What's the best way to do this ?

Something I've done is to create a custom decorator that inserts this
text, and then either have it append or prepend a given element. This is
quick-and-dirty, but gets the job done.

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Gordon Ross-2

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by oreales
On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:

> Well, in that case, there is another option that I have though to implement
> sometimes: extends a custom formElement that renders html. You can call this
> element "text" - "rawHtml" or something similar. Create the formEelement,
> the viewHelper, decorators etc.... It is much more work but once it is done,
> you can uses it in any project.

Out of all the options I've seen so far, I think this one is probably the
best. As you say, though, it may not be the simplest. I'm starting to look
at the existing elements to see what work is involved. I'm hoping it won't
be too much work...

GTG

weierophinney

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
-- Gordon Ross <[hidden email]> wrote
(on Wednesday, 20 August 2008, 06:31 PM +0100):

> On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
>
> > Well, in that case, there is another option that I have though to implement
> > sometimes: extends a custom formElement that renders html. You can call this
> > element "text" - "rawHtml" or something similar. Create the formEelement,
> > the viewHelper, decorators etc.... It is much more work but once it is done,
> > you can uses it in any project.
>
> Out of all the options I've seen so far, I think this one is probably the
> best. As you say, though, it may not be the simplest. I'm starting to look
> at the existing elements to see what work is involved. I'm hoping it won't
> be too much work...

It's not. :)

In this case, I'd suggest simply extending Zend_Form_Element, and then
overriding render() to simply return the element value:

    class My_Form_Element_RawText extends Zend_Form_Element
    {
        public function render(Zend_View_Interface $view = null)
        {
            return $this->getValue();
        }
    }

And that way you can re-use it to enter arbitrary text anywhere:

    $form->addElement('rawText', 'foo', array(
        'value' => 'This is some text to insert somewhere...',
    ));

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Gordon Ross-2

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gordon Ross-2
Thanks for that. Where should I put it ? I don't really want to slap it in the main Zend directories...

GTG

PS If ever you have the unfortunate experience to bump into me, I think I owe you a few beers....

----- Original Message -----
From: Matthew Weier O'Phinney <[hidden email]>
To: [hidden email] <[hidden email]>
Sent: Wed Aug 20 18:59:38 2008
Subject: Re: [fw-mvc] Include raw HTML into Zend_Form

-- Gordon Ross <[hidden email]> wrote
(on Wednesday, 20 August 2008, 06:31 PM +0100):

> On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
>
> > Well, in that case, there is another option that I have though to implement
> > sometimes: extends a custom formElement that renders html. You can call this
> > element "text" - "rawHtml" or something similar. Create the formEelement,
> > the viewHelper, decorators etc.... It is much more work but once it is done,
> > you can uses it in any project.
>
> Out of all the options I've seen so far, I think this one is probably the
> best. As you say, though, it may not be the simplest. I'm starting to look
> at the existing elements to see what work is involved. I'm hoping it won't
> be too much work...

It's not. :)

In this case, I'd suggest simply extending Zend_Form_Element, and then
overriding render() to simply return the element value:

    class My_Form_Element_RawText extends Zend_Form_Element
    {
        public function render(Zend_View_Interface $view = null)
        {
            return $this->getValue();
        }
    }

And that way you can re-use it to enter arbitrary text anywhere:

    $form->addElement('rawText', 'foo', array(
        'value' => 'This is some text to insert somewhere...',
    ));

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
weierophinney

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
-- Gordon Ross <[hidden email]> wrote
(on Wednesday, 20 August 2008, 10:11 PM +0100):
> Thanks for that. Where should I put it ? I don't really want to slap
> it in the main Zend directories...

Well, as the class is called "My_Form_Element_RawText", I'd put it in
library/My/Form/Element/RawText.php.

Basically, we recommend you create your own, unique namespace prefix --
such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
top-level directory underneath your library/ directory (which will
contain Zend/ as well), and you should be all set.

You'll need to tell Zend_Form about the location of this prefix, though;
you can do that easily enough:
   
    $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');

and you'll be all set to start using it.

> PS If ever you have the unfortunate experience to bump into me, I
> think I owe you a few beers....

I won't say no. :)

> ----- Original Message -----
> From: Matthew Weier O'Phinney <[hidden email]>
> To: [hidden email] <[hidden email]>
> Sent: Wed Aug 20 18:59:38 2008
> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>
> -- Gordon Ross <[hidden email]> wrote
> (on Wednesday, 20 August 2008, 06:31 PM +0100):
> > On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
> >
> > > Well, in that case, there is another option that I have though to implement
> > > sometimes: extends a custom formElement that renders html. You can call this
> > > element "text" - "rawHtml" or something similar. Create the formEelement,
> > > the viewHelper, decorators etc.... It is much more work but once it is done,
> > > you can uses it in any project.
> >
> > Out of all the options I've seen so far, I think this one is probably the
> > best. As you say, though, it may not be the simplest. I'm starting to look
> > at the existing elements to see what work is involved. I'm hoping it won't
> > be too much work...
>
> It's not. :)
>
> In this case, I'd suggest simply extending Zend_Form_Element, and then
> overriding render() to simply return the element value:
>
>     class My_Form_Element_RawText extends Zend_Form_Element
>     {
>         public function render(Zend_View_Interface $view = null)
>         {
>             return $this->getValue();
>         }
>     }
>
> And that way you can re-use it to enter arbitrary text anywhere:
>
>     $form->addElement('rawText', 'foo', array(
>         'value' => 'This is some text to insert somewhere...',
>     ));
>
> --
> Matthew Weier O'Phinney
> Software Architect       | [hidden email]
> Zend Framework           | http://framework.zend.com/

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
oreales

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
Well at the end, the solution that Matthew purpose and the solution I
purposed before are the same: extends the Zend_Form_Element to creat your
own formElement (rawHtml). But i can´t understand why Matthew you says it is
"best" to overwrite "render" method instead of create the correspondant view
helpers, etc... For this "new element"......

If all you need is to render the "rawHtml" you can do that in the
viewHelper, but the form Element will behave in a standard way. ViewHelpers
of the Form Elements are quite useful: recently I have finished a project
where i need to render the output of form elements in "extjs" instead of
"xhtml"....... Creating different view helpers for each different form
element did the job without change nothing at the "form creation"
level........ This is why i suggest create Element, Helpers, etc....

Overriding the render() method, the new "My_Form_Element_RawText" will not
have the possibility of using "decorators", etc..., the standard behavior of
a "Form_Element" will be broken, will it not???.....



On 21/08/2008 16:08, "Matthew Weier O'Phinney" <[hidden email]> wrote:

> -- Gordon Ross <[hidden email]> wrote
> (on Wednesday, 20 August 2008, 10:11 PM +0100):
>> Thanks for that. Where should I put it ? I don't really want to slap
>> it in the main Zend directories...
>
> Well, as the class is called "My_Form_Element_RawText", I'd put it in
> library/My/Form/Element/RawText.php.
>
> Basically, we recommend you create your own, unique namespace prefix --
> such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
> top-level directory underneath your library/ directory (which will
> contain Zend/ as well), and you should be all set.
>
> You'll need to tell Zend_Form about the location of this prefix, though;
> you can do that easily enough:
>    
>     $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
>
> and you'll be all set to start using it.
>
>> PS If ever you have the unfortunate experience to bump into me, I
>> think I owe you a few beers....
>
> I won't say no. :)
>
>> ----- Original Message -----
>> From: Matthew Weier O'Phinney <[hidden email]>
>> To: [hidden email] <[hidden email]>
>> Sent: Wed Aug 20 18:59:38 2008
>> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>>
>> -- Gordon Ross <[hidden email]> wrote
>> (on Wednesday, 20 August 2008, 06:31 PM +0100):
>>> On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
>>>
>>>> Well, in that case, there is another option that I have though to implement
>>>> sometimes: extends a custom formElement that renders html. You can call
>>>> this
>>>> element "text" - "rawHtml" or something similar. Create the formEelement,
>>>> the viewHelper, decorators etc.... It is much more work but once it is
>>>> done,
>>>> you can uses it in any project.
>>>
>>> Out of all the options I've seen so far, I think this one is probably the
>>> best. As you say, though, it may not be the simplest. I'm starting to look
>>> at the existing elements to see what work is involved. I'm hoping it won't
>>> be too much work...
>>
>> It's not. :)
>>
>> In this case, I'd suggest simply extending Zend_Form_Element, and then
>> overriding render() to simply return the element value:
>>
>>     class My_Form_Element_RawText extends Zend_Form_Element
>>     {
>>         public function render(Zend_View_Interface $view = null)
>>         {
>>             return $this->getValue();
>>         }
>>     }
>>
>> And that way you can re-use it to enter arbitrary text anywhere:
>>
>>     $form->addElement('rawText', 'foo', array(
>>         'value' => 'This is some text to insert somewhere...',
>>     ));
>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect       | [hidden email]
>> Zend Framework           | http://framework.zend.com/


weierophinney

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
-- Oscar Reales <[hidden email]> wrote
(on Thursday, 21 August 2008, 04:54 PM +0200):
> Well at the end, the solution that Matthew purpose and the solution I
> purposed before are the same: extends the Zend_Form_Element to creat your
> own formElement (rawHtml). But i can´t understand why Matthew you says it is
> "best" to overwrite "render" method instead of create the correspondant view
> helpers, etc... For this "new element"......

Because if all you're doing is rendering text verbatim, and there's no
need for extra decorators, then this is the simplest, most
straight-forward solution.

> If all you need is to render the "rawHtml" you can do that in the
> viewHelper, but the form Element will behave in a standard way. ViewHelpers
> of the Form Elements are quite useful: recently I have finished a project
> where i need to render the output of form elements in "extjs" instead of
> "xhtml"....... Creating different view helpers for each different form
> element did the job without change nothing at the "form creation"
> level........ This is why i suggest create Element, Helpers, etc....
>
> Overriding the render() method, the new "My_Form_Element_RawText" will not
> have the possibility of using "decorators", etc..., the standard behavior of
> a "Form_Element" will be broken, will it not???.....
>
>
>
> On 21/08/2008 16:08, "Matthew Weier O'Phinney" <[hidden email]> wrote:
>
> > -- Gordon Ross <[hidden email]> wrote
> > (on Wednesday, 20 August 2008, 10:11 PM +0100):
> >> Thanks for that. Where should I put it ? I don't really want to slap
> >> it in the main Zend directories...
> >
> > Well, as the class is called "My_Form_Element_RawText", I'd put it in
> > library/My/Form/Element/RawText.php.
> >
> > Basically, we recommend you create your own, unique namespace prefix --
> > such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
> > top-level directory underneath your library/ directory (which will
> > contain Zend/ as well), and you should be all set.
> >
> > You'll need to tell Zend_Form about the location of this prefix, though;
> > you can do that easily enough:
> >    
> >     $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
> >
> > and you'll be all set to start using it.
> >
> >> PS If ever you have the unfortunate experience to bump into me, I
> >> think I owe you a few beers....
> >
> > I won't say no. :)
> >
> >> ----- Original Message -----
> >> From: Matthew Weier O'Phinney <[hidden email]>
> >> To: [hidden email] <[hidden email]>
> >> Sent: Wed Aug 20 18:59:38 2008
> >> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
> >>
> >> -- Gordon Ross <[hidden email]> wrote
> >> (on Wednesday, 20 August 2008, 06:31 PM +0100):
> >>> On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
> >>>
> >>>> Well, in that case, there is another option that I have though to implement
> >>>> sometimes: extends a custom formElement that renders html. You can call
> >>>> this
> >>>> element "text" - "rawHtml" or something similar. Create the formEelement,
> >>>> the viewHelper, decorators etc.... It is much more work but once it is
> >>>> done,
> >>>> you can uses it in any project.
> >>>
> >>> Out of all the options I've seen so far, I think this one is probably the
> >>> best. As you say, though, it may not be the simplest. I'm starting to look
> >>> at the existing elements to see what work is involved. I'm hoping it won't
> >>> be too much work...
> >>
> >> It's not. :)
> >>
> >> In this case, I'd suggest simply extending Zend_Form_Element, and then
> >> overriding render() to simply return the element value:
> >>
> >>     class My_Form_Element_RawText extends Zend_Form_Element
> >>     {
> >>         public function render(Zend_View_Interface $view = null)
> >>         {
> >>             return $this->getValue();
> >>         }
> >>     }
> >>
> >> And that way you can re-use it to enter arbitrary text anywhere:
> >>
> >>     $form->addElement('rawText', 'foo', array(
> >>         'value' => 'This is some text to insert somewhere...',
> >>     ));
> >>
> >> --
> >> Matthew Weier O'Phinney
> >> Software Architect       | [hidden email]
> >> Zend Framework           | http://framework.zend.com/
>
>

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
oreales

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink


On 21/08/2008 17:46, "Matthew Weier O'Phinney" <[hidden email]> wrote:

> -- Oscar Reales <[hidden email]> wrote
> (on Thursday, 21 August 2008, 04:54 PM +0200):
>> Well at the end, the solution that Matthew purpose and the solution I
>> purposed before are the same: extends the Zend_Form_Element to creat your
>> own formElement (rawHtml). But i can´t understand why Matthew you says it is
>> "best" to overwrite "render" method instead of create the correspondant view
>> helpers, etc... For this "new element"......
>
> Because if all you're doing is rendering text verbatim, and there's no
> need for extra decorators, then this is the simplest, most
> straight-forward solution.

Ok. So is not the "best" solution but the simplest one. Then, i insist:
would be much better to do it at the right way. "Code today thinking in
tomorrow" is my way of see it. If you do it at the right way once, then you
can uses it at future projects without change nothing and following the
Zend_Form_Elements conventions.


>
>> If all you need is to render the "rawHtml" you can do that in the
>> viewHelper, but the form Element will behave in a standard way. ViewHelpers
>> of the Form Elements are quite useful: recently I have finished a project
>> where i need to render the output of form elements in "extjs" instead of
>> "xhtml"....... Creating different view helpers for each different form
>> element did the job without change nothing at the "form creation"
>> level........ This is why i suggest create Element, Helpers, etc....
>>
>> Overriding the render() method, the new "My_Form_Element_RawText" will not
>> have the possibility of using "decorators", etc..., the standard behavior of
>> a "Form_Element" will be broken, will it not???.....
>>
>>
>>
>> On 21/08/2008 16:08, "Matthew Weier O'Phinney" <[hidden email]> wrote:
>>
>>> -- Gordon Ross <[hidden email]> wrote
>>> (on Wednesday, 20 August 2008, 10:11 PM +0100):
>>>> Thanks for that. Where should I put it ? I don't really want to slap
>>>> it in the main Zend directories...
>>>
>>> Well, as the class is called "My_Form_Element_RawText", I'd put it in
>>> library/My/Form/Element/RawText.php.
>>>
>>> Basically, we recommend you create your own, unique namespace prefix --
>>> such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
>>> top-level directory underneath your library/ directory (which will
>>> contain Zend/ as well), and you should be all set.
>>>
>>> You'll need to tell Zend_Form about the location of this prefix, though;
>>> you can do that easily enough:
>>>    
>>>     $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
>>>
>>> and you'll be all set to start using it.
>>>
>>>> PS If ever you have the unfortunate experience to bump into me, I
>>>> think I owe you a few beers....
>>>
>>> I won't say no. :)
>>>
>>>> ----- Original Message -----
>>>> From: Matthew Weier O'Phinney <[hidden email]>
>>>> To: [hidden email] <[hidden email]>
>>>> Sent: Wed Aug 20 18:59:38 2008
>>>> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>>>>
>>>> -- Gordon Ross <[hidden email]> wrote
>>>> (on Wednesday, 20 August 2008, 06:31 PM +0100):
>>>>> On 19/08/2008 09:05, "Oscar Reales" <[hidden email]> wrote:
>>>>>
>>>>>> Well, in that case, there is another option that I have though to
>>>>>> implement
>>>>>> sometimes: extends a custom formElement that renders html. You can call
>>>>>> this
>>>>>> element "text" - "rawHtml" or something similar. Create the formEelement,
>>>>>> the viewHelper, decorators etc.... It is much more work but once it is
>>>>>> done,
>>>>>> you can uses it in any project.
>>>>>
>>>>> Out of all the options I've seen so far, I think this one is probably the
>>>>> best. As you say, though, it may not be the simplest. I'm starting to look
>>>>> at the existing elements to see what work is involved. I'm hoping it won't
>>>>> be too much work...
>>>>
>>>> It's not. :)
>>>>
>>>> In this case, I'd suggest simply extending Zend_Form_Element, and then
>>>> overriding render() to simply return the element value:
>>>>
>>>>     class My_Form_Element_RawText extends Zend_Form_Element
>>>>     {
>>>>         public function render(Zend_View_Interface $view = null)
>>>>         {
>>>>             return $this->getValue();
>>>>         }
>>>>     }
>>>>
>>>> And that way you can re-use it to enter arbitrary text anywhere:
>>>>
>>>>     $form->addElement('rawText', 'foo', array(
>>>>         'value' => 'This is some text to insert somewhere...',
>>>>     ));
>>>>
>>>> --
>>>> Matthew Weier O'Phinney
>>>> Software Architect       | [hidden email]
>>>> Zend Framework           | http://framework.zend.com/
>>
>>


Gordon Ross-2

RE: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by weierophinney
Is there a way to add this to be a included by default ?

GTG
________________________________________
From: Matthew Weier O'Phinney [[hidden email]]
Sent: 21 August 2008 15:08
To: [hidden email]
Subject: Re: [fw-mvc] Include raw HTML into Zend_Form

-- Gordon Ross <[hidden email]> wrote
(on Wednesday, 20 August 2008, 10:11 PM +0100):
> Thanks for that. Where should I put it ? I don't really want to slap
> it in the main Zend directories...

Well, as the class is called "My_Form_Element_RawText", I'd put it in
library/My/Form/Element/RawText.php.

Basically, we recommend you create your own, unique namespace prefix --
such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
top-level directory underneath your library/ directory (which will
contain Zend/ as well), and you should be all set.

You'll need to tell Zend_Form about the location of this prefix, though;
you can do that easily enough:

    $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');

and you'll be all set to start using it.
weierophinney

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
-- Gordon Ross <[hidden email]> wrote
(on Friday, 22 August 2008, 03:15 PM +0100):
> Is there a way to add this to be a included by default ?

As in you'd like it in the standard ZF distribution, or that you want
the plugin path enabled by default?

If you would like something like this in the standard ZF distribution,
please file a feature request in the issue tracker.

> ________________________________________
> From: Matthew Weier O'Phinney [[hidden email]]
> Sent: 21 August 2008 15:08
> To: [hidden email]
> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>
> -- Gordon Ross <[hidden email]> wrote
> (on Wednesday, 20 August 2008, 10:11 PM +0100):
> > Thanks for that. Where should I put it ? I don't really want to slap
> > it in the main Zend directories...
>
> Well, as the class is called "My_Form_Element_RawText", I'd put it in
> library/My/Form/Element/RawText.php.
>
> Basically, we recommend you create your own, unique namespace prefix --
> such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
> top-level directory underneath your library/ directory (which will
> contain Zend/ as well), and you should be all set.
>
> You'll need to tell Zend_Form about the location of this prefix, though;
> you can do that easily enough:
>
>     $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
>
> and you'll be all set to start using it.
>

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Gabriel Baez-2

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
This was very handy,  thanks  :)


On Fri, Aug 22, 2008 at 9:53 AM, Matthew Weier O'Phinney <[hidden email]> wrote:
-- Gordon Ross <[hidden email]> wrote
(on Friday, 22 August 2008, 03:15 PM +0100):
> Is there a way to add this to be a included by default ?

As in you'd like it in the standard ZF distribution, or that you want
the plugin path enabled by default?

If you would like something like this in the standard ZF distribution,
please file a feature request in the issue tracker.

> ________________________________________
> From: Matthew Weier O'Phinney [[hidden email]]
> Sent: 21 August 2008 15:08
> To: [hidden email]
> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form
>
> -- Gordon Ross <[hidden email]> wrote
> (on Wednesday, 20 August 2008, 10:11 PM +0100):
> > Thanks for that. Where should I put it ? I don't really want to slap
> > it in the main Zend directories...
>
> Well, as the class is called "My_Form_Element_RawText", I'd put it in
> library/My/Form/Element/RawText.php.
>
> Basically, we recommend you create your own, unique namespace prefix --
> such as we have 'Zend_', and Solar uses 'Solar_', etc. Use this as a
> top-level directory underneath your library/ directory (which will
> contain Zend/ as well), and you should be all set.
>
> You'll need to tell Zend_Form about the location of this prefix, though;
> you can do that easily enough:
>
>     $form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
>
> and you'll be all set to start using it.
>

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/


Zladivliba

Multiple submit buttons on a Zend_Form

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
That's a noob question, but I ZendDoc'ed and googled all arround, and just can't find the answer : I have multiple submit buttons on a Zend_Dojo_Form, how do we know wich one was clicked by the user ?

Z.




Discutez gratuitement avec vos amis en vidéo ! Téléchargez Messenger, c'est gratuit !
smast

Re: Include raw HTML into Zend_Form

Reply Threaded More More options
Print post
Permalink
In reply to this post by weierophinney
Matthew Weier O'Phinney-3 wrote:
    class My_Form_Element_RawText extends Zend_Form_Element
    {
        public function render(Zend_View_Interface $view = null)
        {
            return $this->getValue();
        }
    }

And that way you can re-use it to enter arbitrary text anywhere:

    $form->addElement('rawText', 'foo', array(
        'value' => 'This is some text to insert somewhere...',
    ));
FYI, I had some funky issues with elements dissaprearing once I tried to validate etc, so I also had to overide the isValid method in Zend_Form_Element

    //needs to always validate as true
    public function isValid($value, $context = null)
    {
    return true;
    }