Example #1
0
 public function loadButtons()
 {
     $buttons = Zend_Controller_Front::getInstance()->getRequest()->getParam('buttons');
     if (!count($buttons)) {
         $buttons = array();
     }
     if (!$buttons['Salvar']) {
         $edit = Zend_Controller_Front::getInstance()->getRequest()->getParam('edit');
         $success = "";
         if (!$edit) {
             $success = "location.reload();";
         } else {
             $success = "window.location.href = \$('#content-button-edit').attr('href');";
         }
         $onClick = "function(){\n                                var form = jQuery('#" . $this->_formNome . "');\n                                jQuery.AjaxT.submitJson({\n                                    selector: form,\n                                    success: function(result){\n                                        {$success}\n                                    }\n                                });\n                            }";
         $_button = new ZendT_Form_Element_Button('salvar-dynamic');
         $_button->setIcon('ui-icon-check');
         $_button->addClass('btn btn-primary');
         $_button->setLabel('Salvar');
         $_button->setAttrib('onClick', new ZendT_JS_Command($onClick));
         $_button->addDecorator(new ZendT_Form_Decorator_Button());
         $_button->addStyle('float', 'right');
         $this->addElement($_button);
         /* $buttons['Salvar'] = $_button;
            Zend_Controller_Front::getInstance()->getRequest()->setParam('buttons', $buttons); */
     }
 }