|
View:
New views
18 Messages
—
Rating Filter:
Alert me
|
|
|
Include raw HTML into Zend_FormIs 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 |
|
|
Re: Include raw HTML into Zend_FormGordon 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 |
|
|
Re: Include raw HTML into Zend_FormIf 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" <gr306@...> 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 > |
|
|
|
|
|
Re: Include raw HTML into Zend_FormWell, 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" <gr306@...> wrote: > Using descriptors isn't applicable in this case. > > Thanks anyway. > > GTG > > ----- Original Message ----- > From: Oscar Reales <oreales@...> > To: fw-mvc@... <fw-mvc@...> > 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" <gr306@...> 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 >> > > |
|
|
Re: Include raw HTML into Zend_Form-- Gordon Ross <gr306@...> 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 | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Include raw HTML into Zend_FormOn 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 |
|
|
Re: Include raw HTML into Zend_Form-- Gordon Ross <gr306@...> wrote
(on Wednesday, 20 August 2008, 06:31 PM +0100): > On 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
|
|
|
Re: Include raw HTML into Zend_Form-- Gordon Ross <gr306@...> 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 <matthew@...> > To: fw-mvc@... <fw-mvc@...> > Sent: Wed Aug 20 18:59:38 2008 > Subject: Re: [fw-mvc] Include raw HTML into Zend_Form > > -- Gordon Ross <gr306@...> wrote > (on Wednesday, 20 August 2008, 06:31 PM +0100): > > On 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 | matthew@... > Zend Framework | http://framework.zend.com/ -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Include raw HTML into Zend_FormWell 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" <matthew@...> wrote: > -- Gordon Ross <gr306@...> 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 <matthew@...> >> To: fw-mvc@... <fw-mvc@...> >> Sent: Wed Aug 20 18:59:38 2008 >> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form >> >> -- Gordon Ross <gr306@...> wrote >> (on Wednesday, 20 August 2008, 06:31 PM +0100): >>> On 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 | matthew@... >> Zend Framework | http://framework.zend.com/ |
|
|
Re: Include raw HTML into Zend_Form-- Oscar Reales <oreales@...> 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" <matthew@...> wrote: > > > -- Gordon Ross <gr306@...> 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 <matthew@...> > >> To: fw-mvc@... <fw-mvc@...> > >> Sent: Wed Aug 20 18:59:38 2008 > >> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form > >> > >> -- Gordon Ross <gr306@...> wrote > >> (on Wednesday, 20 August 2008, 06:31 PM +0100): > >>> On 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 | matthew@... > >> Zend Framework | http://framework.zend.com/ > > -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Include raw HTML into Zend_FormOn 21/08/2008 17:46, "Matthew Weier O'Phinney" <matthew@...> wrote: > -- Oscar Reales <oreales@...> 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" <matthew@...> wrote: >> >>> -- Gordon Ross <gr306@...> 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 <matthew@...> >>>> To: fw-mvc@... <fw-mvc@...> >>>> Sent: Wed Aug 20 18:59:38 2008 >>>> Subject: Re: [fw-mvc] Include raw HTML into Zend_Form >>>> >>>> -- Gordon Ross <gr306@...> wrote >>>> (on Wednesday, 20 August 2008, 06:31 PM +0100): >>>>> On 19/08/2008 09:05, "Oscar Reales" <oreales@...> 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 | matthew@... >>>> Zend Framework | http://framework.zend.com/ >> >> |
|
|
RE: Include raw HTML into Zend_FormIs there a way to add this to be a included by default ?
GTG ________________________________________ From: Matthew Weier O'Phinney [matthew@...] Sent: 21 August 2008 15:08 To: fw-mvc@... Subject: Re: [fw-mvc] Include raw HTML into Zend_Form -- Gordon Ross <gr306@...> 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. |
|
|
Re: Include raw HTML into Zend_Form-- Gordon Ross <gr306@...> 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 [matthew@...] > Sent: 21 August 2008 15:08 > To: fw-mvc@... > Subject: Re: [fw-mvc] Include raw HTML into Zend_Form > > -- Gordon Ross <gr306@...> 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 | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Include raw HTML into Zend_FormThis was very handy, thanks :)
On Fri, Aug 22, 2008 at 9:53 AM, Matthew Weier O'Phinney <matthew@...> wrote:
|
|
|
Multiple submit buttons on a Zend_FormZ. Discutez gratuitement avec vos amis en vidéo ! Téléchargez Messenger, c'est gratuit ! |
|
|
Re: Include raw HTML into Zend_FormFYI, 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; } |
| Free embeddable forum powered by Nabble | Forum Help |