2009年7月17日星期五

Re: [fw-mvc] Adding custom HTML to Form?

Hi Ken, I have the same problem... I'm just wondering if you solved the
problem (and if, how :-D )
Thank you


dinoboff wrote:
>
> I think they fixed it in the trunk:
> http://framework.zend.com/issues/browse/ZF-2735
>
> However it might be better to use something else than the value property
> to create your element.
>
>
>
> kcrane377 wrote:
>>
>> I created my own element and view helper and everything shows up perfect
>> but the problem i have is my element gets nulled out when the form fails
>> validation.
>>
>> Is this the intended behavior?
>>
>> Ken
>>
>>
>> dinoboff wrote:
>>>
>>> Your toolbar with need javascript to work, so you are better to add the
>>> toolbar on the client-side.
>>> If you were adding YUI rich text editor, the textarea just need an id:
>>>
>>> var myEditor = new YAHOO.widget.Editor('textareaId', {
>>> height: '300px',
>>> width: '522px',
>>> dompath: true, //Turns on the bar at the bottom
>>> animate: true //Animates the opening, closing and moving of Editor
>>> windows
>>> });
>>> myEditor.render();
>>>
>>> For adding any html to the form, you can create your own element.
>>> something like that:
>>>
>>> require_once 'Zend/Form/Element/Xhtml.php';
>>>
>>> class My_Form_Element_Note extends Zend_Form_Element_Xhtml
>>> {
>>> /**
>>> * Default form view helper to use for rendering
>>> * @var string
>>> */
>>> public $helper = 'formNote';
>>> }
>>>
>>> (I don't know if formNote is meant to be used for that, but you can use
>>> your own view helper)
>>>
>>> Then you add the element like that:
>>> $note = new My_Form_Element_Note('note');
>>> $note->setValue('<p>Some notes...</p>');
>>> $note->addDecorators(array(
>>> 'ViewHelper',
>>> array('HtmlTag', array('tag' => 'li')) // which ever element you use
>>> to wrap your elements in the form
>>> ));
>>>
>>> $form->addElement($note);
>>>
>>> I thought I would need something like that, but using elements or
>>> display group descriptions is good enough.
>>>
>>>
>>> kcrane377 wrote:
>>>>
>>>> I would like to add html to a form i am creating. Most obvious would
>>>> be a tool bar above a text area for editing text (bold, italic, image,
>>>> etc.) as seen on almost every forum but i would also like the ability
>>>> to add anything for that matter (text, lists, etc) anywhere in the
>>>> form.
>>>>
>>>> In Pear QuickForm you had the HTML element to solve this problem. What
>>>> is ZF's way of accomplishing this using Zend Form?
>>>>
>>>> Ken
>>>>
>>>
>>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Adding-custom-HTML-to-Form--tp15920982p24537813.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: