<?php 
 class Application_Model_Form_UserEdit extends MyWeb_Form
{

    public function init()
    {
    	ZendX_JQuery::enableForm($this);	// zapnuti jQuery
    	
        $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_user_edit");
        
        
        //nacteni config souboru s definovan7mi fomularovymi prvky
        $config = new Zend_Config_Ini(APPLICATION_PATH . "/forms/userEdit.ini");
        $this->setConfig($config);
        
        $user = $this->_model->fetchEntry(NULL);
        
        //***************************************************************************
         $element = $this->getElement('user_name');
         $element->setLabel($translate->translate('Name'));
        //***************************************************************************
         $element = $this->getElement('user_userName');
         $element->setLabel($translate->translate('Username'));
        //***************************************************************************
         $element = $this->getElement('user_passwd');
         $element->setLabel($translate->translate('Password'));
         //***************************************************************************
        $user_registrationDateTime = new ZendX_JQuery_Form_Element_DatePicker("user_registrationDateTime",''
        ,array('defaultDate' => date('yy')));
        $user_registrationDateTime->setLabel($translate->translate('Date'));
        $user_registrationDateTime->setAttrib('Disabled', '');
        //***************************************************************************
        $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')); 
        
        
        //*** 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_state = new Zend_Form_Element_Hidden('State_id_state');
        $State_id_state->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);
        //***************************************************************************
        
        // vytvoří formulářový prvek tlačítko
        $submitInsert = new Zend_Form_Element_Submit("send", array("label" => $translate->translate('Edit')));
        $submitDelete = new Zend_Form_Element_Submit("delete", array("label" => $translate->translate('Delete')));
        // přidá formulářové prvky do formuláře
        
        $this->addElements(array($user_registrationDateTime));
        $this->addDisplayGroup(array(
        								'user_name',
        								'user_userName',
        								'user_registrationDateTime',
        								'user_passwd',
        								'State_id_stateValue',
        								'delete',
        
        								'State_id_stateInputName',
        								'State_id_state',
        
        								'nameState_nameInputName',
        								'nameState_nameInputValue'
        
        							),'formRoleEdit',array('legend' => $translate->translate('State')));
        $this->addElements(array(
        							$submitInsert,
        							$submitDelete,
        							
        							$State_id_stateInputName,
        							$State_id_state,
        							$nameState_nameInputName,
        							$nameState_nameInputValue
        						));
        						//$this->removeElement('user_name');
    }


}
