<?php 
 class Application_Model_Form_CommentEdit extends MyWeb_Form
{

    public function init()
    {
        $root = 'index.php';
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $getValue = $request->getParams();
        $path = explode($root, $request->getRequestUri());
        $translate = Zend_Registry::get('Zend_Translate');
        
        // nastaví atributy formuláře
        $this->setAction("edit");
        $this->setMethod("post");
        $this->setAttrib("id", "form_comment_edit");
        //nacteni config souboru s definovan7mi fomularovymi prvky
        $config = new Zend_Config_Ini(APPLICATION_PATH . "/forms/commentEdit.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');
        
        
        
        //***************************************************************************
        
        $commentName = new Zend_Form_Element_Text('commentName');
        $commentName->setLabel($translate->translate('Name'));
        
        //***************************************************************************
        $url = new Zend_View_Helper_Url();
        
        $link = '<a href = "'."javascript:load0()".'">'.$translate->translate('State').'</a>';
        $element = $this->getElement('State_id_stateValue');
        $element->setLabel($translate->translate('State'));
        $element->setDescription( $link );
        $element->setDecorators(	array('ViewHelper',array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors')); 
        //$element->setAttrib('disabled',"");
        
        //*** vytvoreni hidden poli pro jmeno hodnoty a hodnotu
        $State_id_stateInputName = new Zend_Form_Element_Hidden('State_id_stateInputName');
        $State_id_stateInputName->setValue(NULL);
        $State_id_stateInputValue = new Zend_Form_Element_Hidden('State_id_stateInputValue');
        $State_id_stateInputValue->setValue(NULL);
        
        $nameState_nameInputName = new Zend_Form_Element_Hidden('nameState_nameInputName');
        $nameState_nameInputName->setValue(NULL);
        $nameState_nameInputValue = new Zend_Form_Element_Hidden('nameState_nameInputValue');
        $nameState_nameInputValue->setValue(NULL);
        
        //***************************************************************************
        $url = new Zend_View_Helper_Url();
        
        $link = '<a href = "'."javascript:load1()".'">'.$translate->translate('Article').'</a>';
        $element = $this->getElement('Article_id_articleValue');
        $element->setLabel($translate->translate('Article'));
        $element->setDescription( $link );
        $element->setDecorators(	array('ViewHelper',array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors'));
        $element->removeDecorator('Description');
        $element->setAttrib('disabled',"");
        
        
        //*** vytvoreni hidden poli pro jmeno hodnoty a hodnotu
        $Article_id_articleInputName = new Zend_Form_Element_Hidden('Article_id_articleInputName');
        $Article_id_articleInputName->setValue(NULL);
        $Article_id_articleInputValue = new Zend_Form_Element_Hidden('Article_id_articleInputValue');
        $Article_id_articleInputValue->setValue(NULL);
        
        $article_textInputName = new Zend_Form_Element_Hidden('article_textInputName');
        $article_textInputName->setValue(NULL);
        $article_textInputValue = new Zend_Form_Element_Hidden('article_textInputValue');
        $article_textInputValue->setValue(NULL);
        //***************************************************************************
        $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', 130)
        				->setAttrib('rows', 30);
        				//->addValidator('NotEmpty', true);
        //*********************************************************************************
        
        
        // vytvoří formulářový prvek odesílací tlačítko
        $submitInsert = new Zend_Form_Element_Submit("send", array("label" => $translate->translate('Edit')));
        // přidá formulářové prvky do formuláře
        $this->addElements(array(
        							$State_id_stateInputName,
        							$State_id_stateInputValue,
        							$nameState_nameInputName,
        							$nameState_nameInputValue,
        							
        							$Article_id_articleInputName,
        							$Article_id_articleInputValue,
        							$article_textInputName,
        							$article_textInputValue,
        							
        							$Article_id_article,
        							//$id_comment,
        							$State_id_state,
        							$comment_dateTime,
        							
        							$commentName,
        							$comment_text
        							));
        
        $this->addDisplayGroup(array(
        								//'id_comment',
        								'commentName',
        								'comment_text',
        								'comment_dateTime',
        								'Article_id_article',
        								'State_id_state',
        								
        								
        								'Article_id_articleValue',
        								'State_id_stateValue',
        
        								'State_id_stateInputName',
        								'State_id_stateInputValue',
        								'nameState_nameInputName',
        								'nameState_nameInputValue',
        
        								'Article_id_articleInputName',
        								'Article_id_articleInputValue',
        								'article_textInputName',
        								'article_textInputValue'
        							
        							),'formRoleEdit',array('legend' => $translate->translate('EditComment'),'style' => 'width:635px;'));
        
        							$this->addElements(array($submitInsert));
    }


}
