Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-08-2008, 03:20 PM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Custom Form Element with custom ViewHelper

I would like to create a custom Form Element which is essentially a Textarea with some javascript to turn it into a WYSIWYG editor (using NicEditor). I thought the best way to do this would be would be something like this

PHP Code:
class Foo_View_Helper_FormNicEditor extends Zend_View_Helper_FormTextarea
{
    public function 
formNicEditor($name$value$value null$attribs null)
    {
         
$textarea $this->formTextarea($name$value$attribs);
         return ..........
    } 
   

and then in my custom Form Element to set
PHP Code:
pubic $helper 'formNicEditor' 
...the problem of course being that it doesn't know where to find this ViewHelper.

What I settled on do was overwriting the render method as follows:

PHP Code:
public function render(Zend_View_Interface $view null
{
         
$view $this->getView();
         
$view->setHelperPath('Foo/View/Helper''Chintion_View_Helper');
         return 
parent::render($view);

This works, but it doesn't feel right to me...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-08-2008, 05:59 PM
Junior Member
 
Join Date: Apr 2008
Posts: 8
Default

you can set setHelperPath() whereever in the code. for example you can execute it in the action method where it will be used.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-09-2008, 03:02 PM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

True, but I would prefer that the element live "self-sufficiently"...I want the element to be ready to be used anywhere in my application (and in any other application).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 08:42 PM
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default

In my apps I set the view helper path in the bootstrap.

PHP Code:

$viewRenderer 
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');

$viewRenderer->initView();

//include our custom helpers
$viewRenderer->view->addHelperPath(APPLICATION_DIRECTORY '/views/helpers''My_View_Helper'); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-11-2008, 01:38 AM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

Thanks...I think that was exactly what I was looking for
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:15 AM.