<?php 
 class Application_Model_Form_CommentNew extends MyWeb_Form
{

    public function init()
    {
        $root = 'index.php';
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $getValue = $request->getParams();
        $path = explode($root, $request->getRequestUri());
        
        
        // nastaví atributy formuláře
        $this->setAction("new");
        
        $this->setMethod("post");
        $this->setAttrib("id", "form_comment_new");
        //nacteni config souboru s definovan7mi fomularovymi prvky
        //$config = new Zend_Config_Ini(APPLICATION_PATH . "/forms/commentNew.ini");
        //$this->setConfig($config);
        
        $comment = $this->_model->fetchEntry(NULL);
        
        //**************************************************************************
        //!!! hidden pole jsou nutna ve formulari protoze getValue porovnava hodnoty s prvky formulare
        $Article_id_article = new Zend_Form_Element_Hidden('Article_id_article');
        
        $State_id_state = new Zend_Form_Element_Hidden('State_id_state');
        
        $comment_dateTime = new Zend_Form_Element_Hidden('comment_dateTime');
        
        $controllerName = new Zend_Form_Element_Hidden('controllerName');
        $controllerName->setValue($request->getControllerName());
        
        
        //***************************************************************************
        
        $commentName = new Zend_Form_Element_Text('commentName');
        $commentName->setLabel('Name');
        
        //***************************************************************************
        $comment_text = new MyWeb_Sozfo_Form_Element_TinyMce('comment_text', array(
        			'editorOptions' => new Zend_Config_Ini(APPLICATION_PATH . '/configs/tinymcecomment.ini', 'moderator')));
        
        $comment_text	->setRequired(true)
        			->addErrorMessage("The content field is required and can't be empty")
        			->setAttrib('cols', 110)
        			->setAttrib('rows', 30)
        			->setAttribs(array('style' => 'width:500px;','style' => 'margin:0 0 0 0;'))
        			->addValidator('NotEmpty', true);
         //***************************************************************************
        
        // vytvoří formulářový prvek odesílací tlačítko
        $submitInsert = new Zend_Form_Element_Submit("send", array("label" => "new"));
        // přidá formulářové prvky do formuláře
        $this->addElements(array(	$Article_id_article,
        							$State_id_state,
        							$comment_dateTime,
        							$controllerName,
        							
        							$commentName,
        							$comment_text,
        							
        							));
        
        $this->addDisplayGroup(array(
        								'commentName',
        								'comment_text',
        
        								'comment_dateTime',
        								'Article_id_article',
        								'State_id_state'
        							),'formRoleEdit',array('legend' => 'Formular','style' => 'width:635px;'));
        $this->addElements(array($submitInsert));
    }
}
