php - Zend Framework/Form Elements: Create custom class or? -


I want the result to be a textarea (hookup to the markdown editor). And include a div.wmd-preview element I am currently in my form (extension Zend_Form ) ... I add functionality through decoration

  // init () $ this-> AddElement ('text', 'bio', array ('label' = & gt; 'bio', 'description' => gt; & lt; a href = "http://daringfireball.net/projects/markdown/ Syntax "target =" array (array ('string long', false, array (0, 1000)) has been marked as' decorators', 'get markbook editing / syntax help' 'gt; markdown enabled Array ('ViewHelper', 'Errors', Arrays ('Description', array ('Tag' = & gt; 'P', & lt; / a & gt; 'Save' = & gt; wrong)), 'label', array ('HtmlTag', array ('tag' => gt; 'p'), new Application_Form_Decorator_WmdPreview,)); ... // Add WMD & Amp; $ Boots Deceiving snap = Zend_Controller_Front :: getInstance () - & gt; getParam ('bootstrap'); $ view = $ bootstrap- & gt; getResource ('view'); $ view- & gt; headScript () - & gt; ; Prefiffile ($ view- & gt; base url ("/ js / wmd / wmd.js")) - & gt; preexaxcript ('wmd_options = {"output": "markdown"}' '- & gt; prefix ( $ View- & gt; baseput ("/ JS / Prettytfa / Pretty.JS")); $ View-> Headlink () - & gt; PrependStylesheet ($ view- & gt; baseurl ('/ js / splash / prettify.css')); }  

But if I want most textareas to be wmd-enabled, then I think it could explain all these to a different class? Or some kind of wrapping element? Either way, if I can do something then it would be good

  $ this-> AddElement (new Application_Form_Element_WmdEditor);  

or something like this

If there is an answer to make a custom Zend_Form_Element , how do I do it? Just create a custom view assistant that contains all the markups? What if I want to make other decorations such as errors and details in texture and preview?

Create a new form element square that extends Zend_Form_Element_TextArea:

  Last category Application_Form_Element_WmdEditor Zend_Form_Element_TextArea {Public $ accessory = 'WMDEditor'; }  

And then you say as a visual assistant:

  last category Application_View_Helper_WMDEditor Zend_View_Helper_FormElement Extended {public function WMDEditor ($ name, $ value = Null, $ attribs = null) {// Set it up}}  

In this way you also have all the benefits of standard form element assistants

< / Html>

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -