<?php 
 class Application_Model_Form_ArticleNew extends MyWeb_Form
{

    public function init()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        ZendX_JQuery::enableForm($this);	// zapnuti jQuery
        $getValue = $request->getParams();
        $translate = Zend_Registry::get('Zend_Translate');
        
        // nastaví atributy formuláře
        $this->setAction("new");
        $this->setMethod("post");
        $this->setAttrib("id", "form_article_new");
        //nacteni config souboru s definovan7mi fomularovymi prvky
        $config = new Zend_Config_Ini(APPLICATION_PATH . "/forms/articleNew.ini");
        $this->setConfig($config);
        
        
        //***************************************************************************
        
        //!!! hidden pole jsou nutna ve formulari protoze getValue porovnava hodnoty s prvky formulare
        $user_userName = new Zend_Form_Element_Hidden('user_userName');
        
        $State_id_state = new Zend_Form_Element_Hidden('State_id_state');
        $State_id_state->setValue(NULL);
        $article_dateTime = new Zend_Form_Element_Hidden('article_dateTime');
        $article_dateTime->setValue(NULL);
        $User_id_user = new Zend_Form_Element_Hidden('User_id_user');
        $User_id_user->setValue(NULL);
        
        //***************************************************************************
         $element = $this->getElement('article_text');
         $element->setLabel($translate->translate('Title'));
         //***************************************************************************
        
        $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);
        
        //*********************************************************************************
        $pcontent = new MyWeb_Sozfo_Form_Element_TinyMce('article_content', array(
        			'editorOptions' => new Zend_Config_Ini(APPLICATION_PATH . '/configs/tinymce.ini', 'moderator')));
        
        $pcontent	->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('New')));
        // přidá formulářové prvky do formuláře
        $this->addElements(array(
        							$user_userName,
        							$pcontent,
        							$nameState_nameInputValue,
        							$nameState_nameInputName,
        							$State_id_stateInputValue,
        							$State_id_stateInputName,
        							
        							$User_id_user,
        							$article_dateTime,
        							$State_id_state
        					));
        $this->addDisplayGroup(array(
        								'article_text',
        								'user_userName',
        								'State_id_stateValue',
        								'article_content',
        
        								'nameState_nameInputValue',
        								'nameState_nameInputName',
        								'State_id_stateInputValue',
        								'State_id_stateInputName'
        
        						),'formRoleEdit',array('legend' => $translate->translate('NewArticle'),'style' => 'width:635px;'));
        $this->addElements(array(
        							$submitInsert
        						));
    }


}
