public function actionCreate() { $model = new NewForm(); $form = new Form('codegen.NewForm', $model); if ($form->submitted() && $model->validate()) { self::generateAndSaveForm($model->model); Yii::app()->user->setFlash(Controller::MSG_SUCCESS, 'Форма создана!'); $this->redirect($_SERVER['REQUEST_URI']); } $this->render('create', array('form' => $form)); }
public function render() { $this->getUrlParameters(); if (empty($this->m_RecordId)) { BizSystem::clientProxy()->showClientAlert($this->getMessage("PLEASE_EDIT_A_RECORD")); return; } return parent::render(); }
public function actionNuevo() { $model = new NewForm(); if (isset($_POST['NewForm'])) { // $valid = true; $model->attributes = $_POST['NewForm']; $valid = $model->validate(); Yii::log('submit -> ' . print_r($_POST, true)); Yii::log('model->attributes -> ' . print_r($model->attributes, true)); if ($model->validate()) { $model->guardaDatosGenerales(); } else { // CVarDumper::dump($model->getErrors(),5678,true); // Yii::app()->end(); } } $this->render('nuevo', array('model' => $model)); }
<?php require_once './autoloader.php'; $translator = Zend\I18n\Translator\Translator::factory(array('locale' => 'zh', 'translation_file_patterns' => array('zf' => array('type' => 'PhpArray', 'base_dir' => EVA_LIB_PATH . '/Zend/resources/languages/', 'pattern' => '%s/Zend_Validate.php')))); \Zend\Validator\AbstractValidator::setDefaultTranslator($translator); class NewForm extends \Eva\Form\Form { /** * Form basic elements * * @var array */ protected $baseElements = array('username' => array('name' => 'username', 'type' => 'hidden', 'options' => array('label' => 'Username'), 'attributes' => array('value' => ''))); /** * Form basic Validators * * @var array */ protected $baseFilters = array('username' => array('name' => 'username', 'required' => true, 'filters' => array(), 'validators' => array())); } $form = new \NewForm(); $form->setData(array('username' => '')); $form->isValid(); p($form->getMessages());