✏️ 正在编辑: Cidade.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/forms/Cidade.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_Cidade extends Core_Form { public function init() { $this->setName('f_save_tabela'); $this->addElement('hidden', 'id', array( 'class' => 'invisivel' )); $this->addElement('text', 'nome', array( 'label' => 'Cidade:', 'required' => true )); $this->getElement('nome')->setAttrib('required', 1); $this->addElement('text', 'uf', array( 'label' => 'UF:' )); $front = Zend_Controller_Front::getInstance(); $id = (int)$front->getRequest()->getParam('id'); $options = Core_Combos::getCidadesOptions($id); $select = new Zend_Form_Element_Select('parent_id'); $select->setLabel('Cidade pai:') ->setAttribs(array('class' => 'cidadeAutoComplete')) ->addMultiOptions($options); $this->addElement($select); $this->addElement('button', 'btn_back', array( 'label' => 'Voltar', 'class' => 'bt_back', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/cidade'" )); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save' )); $this->addElement('button', 'btn_new', array( 'label' => 'Novo Cadastro', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/cidade/save'" )); $this->addDisplayGroup(array( 'btn_back', 'btn_save', 'btn_new' ), 'buttons'); } public function isValid($data) { $where = array( 'nome = ?' => $data['nome'], 'uf = ?' => $data['uf'] ); if(isset($data['id']) && $data['id']){ $where['id <> ?'] = $data['id']; } $dbtable = new Model_DbTable_Cidade(); $cidade = $dbtable->fetchRow($where); // pr($cidade,1); if($cidade){ $this->getElement('nome')->addError("Cidade já cadastrada"); return false; } return parent::isValid($data); } }
💾 保存文件
← 返回文件管理器