当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::submitted方法代码示例

本文整理汇总了PHP中Form::submitted方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::submitted方法的具体用法?PHP Form::submitted怎么用?PHP Form::submitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Form的用法示例。


在下文中一共展示了Form::submitted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 /**
  * Edit a role
  */
 public function edit()
 {
     $param = array('id' => 'edit-role-form', 'model' => 'Role', 'reference' => array('id' => $this->roleId), 'fieldsets' => array('form' => array('nofieldset' => true, new HiddenInput(array('field' => 'removable', 'default' => 1, 'readonly' => true)), new TextInput(array('field' => 'name', 'maxlength' => 32, 'label' => Lang::get('roles.form-name-label'), 'required' => true)), new ColorInput(array('field' => 'color', 'label' => Lang::get('roles.form-color-label'), 'default' => '#000'))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new DeleteInput(array('name' => 'delete', 'value' => Lang::get('main.delete-button'), 'notDisplayed' => $this->roleId == -1)), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.load(app.getUri("list-roles"), {selector : "#admin-roles-tab"});');
     foreach (Language::getAll() as $language) {
         $param['fieldsets']['form'][] = new TextInput(array('name' => "translation[{$language->tag}]", "independant" => true, 'required' => $language->tag == LANGUAGE, "label" => Lang::get("roles.role-label-label", array('lang' => $language->tag)), "default" => Lang::exists("roles.role-" . $this->roleId . "-label") ? Lang::get("roles.role-" . $this->roleId . "-label", array(), 0, $language->tag) : ''));
     }
     $form = new Form($param);
     if (!$form->submitted()) {
         return View::make(Theme::getSelected()->getView("dialogbox.tpl"), array('icon' => 'user', 'title' => Lang::get('roles.form-title'), 'page' => $form));
     } else {
         if ($form->submitted() == "delete") {
             $form->delete(Form::NO_EXIT);
             if ($key) {
                 $key->delete();
             }
             return $form->response(Form::STATUS_SUCCESS);
         } else {
             if ($form->check()) {
                 try {
                     $roleId = $form->register(Form::NO_EXIT);
                     // Create the language key for the translations of the role name
                     foreach (App::request()->getBody('translation') as $tag => $translation) {
                         Language::getByTag($tag)->saveTranslations(array('roles' => array("role-{$roleId}-label" => $translation)));
                     }
                     return $form->response(Form::STATUS_SUCCESS);
                 } catch (Exception $e) {
                     return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : "");
                 }
             }
         }
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:35,代码来源:RoleController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Migration();
     $form = new Form('codegen.MigrationForm', $model);
     if ($form->submitted() && $model->validate()) {
         $res = Yii::app()->db->createCommand("SHOW CREATE TABLE {$model->table}")->queryRow();
         $sql = $res['Create Table'];
         $sql = explode("\n", $sql);
         foreach ($sql as $i => $str) {
             if ($i == 0) {
                 continue;
             }
             $sql[$i] = str_repeat(' ', 14) . $str;
         }
         $sql = implode("\n", $sql);
         $dir = APP_PATH . DS . 'modules' . DS . $model->module . DS . 'migrations' . DS;
         if (!is_dir($dir)) {
             mkdir($dir, 0777);
             chmod($dir, 0777);
         }
         $name = 'm' . date('ymd') . '_' . date('His') . '_' . $model->table . '_create';
         $file = $dir . $name . '.php';
         $params = array('name' => $name, 'table' => $model->table, 'sql' => $sql);
         $code = $this->renderPartial('codegen.views.templates.migration', $params, true);
         file_put_contents($file, $code);
         chmod($file, 0777);
         Yii::app()->user->setFlash('success', t('Создана миграция') . ' ' . $name);
     }
     $this->render('create', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:30,代码来源:MigrationAdminController.php

示例3: actionSiteSettings

 /**
  * Редактирует свойства сайта
  */
 public function actionSiteSettings()
 {
     //$settingsForm = ;
     $form_array = SiteSettingsForm::form();
     //$form_array['title'] = Yii::t('cms', 'General settings');
     $form_array['id'] = 'SiteSettings';
     $form_array['activeForm'] = Form::ajaxify($form_array['id']);
     $form_array['buttons'] = array('refresh' => array('type' => 'submit', 'label' => Yii::t('cms', 'Save'), 'title' => Yii::t('cms', 'Save and reload the page')));
     $form = new Form($form_array);
     $form->id = $form_array['id'];
     $form->model = clone Yii::app()->settings->model;
     $form->loadData();
     $this->performAjaxValidation($form->model, null, false);
     if ($form->submitted('refresh')) {
         if ($form->model->validate()) {
             Yii::app()->settings->saveAll($form->model->getAttributes());
             echo '1';
         } else {
             echo '0';
         }
         Yii::app()->end();
     }
     $caption = array('icon' => 'settings', 'label' => Yii::t('cms', 'Site settings'));
     $this->render('/form', array('form' => $form, 'caption' => $caption));
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:28,代码来源:AdminController.php

示例4: actionCreate

 public function actionCreate()
 {
     $model = new Module();
     $form = new Form('codegen.ModuleForm', $model);
     $this->performAjaxValidation($model);
     if ($form->submitted() && $model->validate()) {
         $files = $this->actionGetFiles($model->id, true);
         foreach ($files as $file) {
             $path_info = pathinfo($file);
             if (isset($path_info['extension'])) {
                 mkdir($path_info['dirname'], 0777, true);
                 file_put_contents($file, $this->getCode($model));
                 chmod($file, 0777);
             } else {
                 if (!is_dir($file)) {
                     mkdir($file, 0777, true);
                     chmod($file, 0777);
                 }
             }
         }
         Yii::app()->user->setFlash('success', 'Модуль создан!');
         $this->redirect($_SERVER['REQUEST_URI']);
     }
     $this->render('create', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:25,代码来源:ModuleAdminController.php

示例5: init

 public function init()
 {
     parent::init();
     $id = __CLASS__ . $this->params['content']->id;
     $this->params['profileVar'] = $this->urlParam('view');
     $blank = true;
     if (Yii::app()->request->getParam($this->params['profileVar']) !== null) {
         $profile = User::model()->findByPk(intval(Yii::app()->request->getParam($this->params['profileVar'])));
         if ($profile) {
             $this->params['details'] = Yii::app()->controller->widget('zii.widgets.CDetailView', array('data' => $profile, 'attributes' => $this->makeFields($this->params['content']->displayed_fields, $profile)), true);
             $this->params['profile'] = $profile->getAttributes();
             if (Yii::app()->user->hasRole($profile->send_message) && $profile->id != $this->params['user']->id && $profile->email) {
                 $vm = new VirtualModel($this->params['content']->feedback_form, 'FieldSet');
                 $config = $vm->formMap;
                 $config['id'] = sprintf('%x', crc32(serialize(array_keys($this->params['content']->feedback_form))));
                 $config['buttons'] = array('send' => array('type' => 'submit', 'label' => Yii::t('UnitProfiles.main', 'Send')));
                 $config['activeForm'] = Form::ajaxify($config['id']);
                 $config['activeForm']['clientOptions']['validationUrl'] = '/?r=view/widget&pageWidgetId=' . $this->params['pageWidget']->id . '&' . $this->params['profileVar'] . '=' . $profile->id;
                 $config['activeForm']['clientOptions']['afterValidate'] = "js:function(f,d,h){if (!h) {return true;}}";
                 $form = new Form($config, $vm);
                 if (Yii::app()->request->getParam('ajax-validate') !== null) {
                     echo CActiveForm::validate($vm);
                     Yii::app()->end();
                 }
                 if ($form->submitted('send')) {
                     $vm = $form->model;
                     if ($form->validate()) {
                         $cfg = ContentUnit::loadConfig();
                         $viewFileDir = $cfg['UnitProfiles'] . '.profiles.templates.mail.';
                         $labels = $vm->attributeLabels();
                         foreach ($vm->getAttributes() as $attr => $value) {
                             $tpldata['fields'][$labels[$attr]] = $value;
                         }
                         $tpldata['profile'] = $profile->getAttributes();
                         $tpldata['settings'] = Yii::app()->settings->model->getAttributes();
                         $tpldata['page'] = $this->params['content']->getWidgetPageArray();
                         $registerModel = ModelRegister::model()->find('widget_id > 0');
                         $registerWidget = new WidgetRegister();
                         if ($registerUnit) {
                             $tpldata['profileEditUrl'] = $registerModel->getWidgetUrl();
                             $tpldata['profileEditUrlParams'] = $registerWidget->urlParam('do') . '=edit';
                         }
                         Yii::app()->messenger->send('email', $profile->email, '[' . $_SERVER['HTTP_HOST'] . '] ' . Yii::t('UnitProfiles.main', 'Feedback form'), Yii::app()->controller->renderPartial($viewFileDir . 'feedback', $tpldata, true));
                         Yii::app()->user->setFlash('UnitProfilesSend-permanent', Yii::t('UnitProfiles.main', 'Your message was successfully sent'));
                         Yii::app()->controller->refresh();
                     }
                 }
                 $this->params['feedbackForm'] = $form->render();
             }
         } else {
             $this->params['error'] = Yii::t('UnitProfiles.main', 'Profile not found');
         }
         $blank = false;
     }
     if ($blank) {
         $this->prepareTable();
     }
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:58,代码来源:WidgetProfiles.php

示例6: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $form = new Form('content.MenuForm', $model);
     if ($form->submitted() && $model->save()) {
         $this->redirect($this->createUrl('manage'));
     }
     $this->render('update', ['form' => $form]);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:9,代码来源:MenuAdminController.php

示例7: actionCreateMetric

 public function actionCreateMetric()
 {
     $model = new Metric('create');
     $this->performAjaxValidation($model);
     $form = new Form('regions.metric', $model);
     if ($form->submitted() && $model->appendTo(Metric::getRoot())) {
         //??? o_O
     }
     $this->redirect('/regions/index/index');
 }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:10,代码来源:SaveController.php

示例8: submitted

 function submitted()
 {
     if (parent::submitted()) {
         if ($this->isClicked('Clear')) {
             $this->clearData();
         }
         $this->memorizeAll();
         $this->view->js()->reload()->execute();
     }
 }
开发者ID:romaninsh,项目名称:Agile-Postfix-Admin,代码行数:10,代码来源:Filter.php

示例9: submitted

 function submitted()
 {
     if (parent::submitted()) {
         if ($this->isClicked('Clear')) {
             $this->clearData();
         }
         $this->memorizeAll();
         return true;
     }
 }
开发者ID:respond,项目名称:atk4,代码行数:10,代码来源:Filter.php

示例10: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $form = new Form('social.LabelForm', $model);
     $this->performAjaxValidation($model);
     if ($form->submitted() && $model->save()) {
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('update', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:10,代码来源:LabelAdminController.php

示例11: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $form = new Form('content.PageForm', $model);
     $this->performAjaxValidation($model);
     if ($form->submitted() && $model->save()) {
         $this->redirect(['view', 'id' => $model->id]);
     }
     $this->render('update', ['form' => $form]);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:10,代码来源:PageAdminController.php

示例12: actionCreate

 public function actionCreate()
 {
     $model = new Crud();
     $form = new Form('codegen.CrudForm', $model);
     if ($form->submitted() && $model->validate()) {
         Yii::import('codegen.controllers.FormAdminController');
         FormAdminController::generateAndSaveForm($model->class);
         $params = $model->attributes;
         $params['module'] = AppManager::getModelModule($model->class);
         $controllers_path = 'codegen.views.templates.crud.controllers';
         $controllers_files = glob(Yii::getPathOfAlias($controllers_path) . DS . '*');
         foreach ($controllers_files as $controller_file) {
             $file_name = pathinfo($controller_file, PATHINFO_FILENAME);
             $code = $this->renderPartial($controllers_path . '.' . $file_name, $params, true);
             $file_name = $model->class . $file_name . '.php';
             $dir = MODULES_PATH . $params['module'] . DS . 'controllers' . DS;
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
                 chmod($dir, 0777);
             }
             $file_path = $dir . $file_name;
             file_put_contents($file_path, $code);
             chmod($file_path, 0777);
         }
         $views_path = 'codegen.views.templates.crud.views';
         $views_files = glob(Yii::getPathOfAlias($views_path) . DS . '*' . DS . '*');
         foreach ($views_files as $view_file) {
             $view_file = str_replace(Yii::getPathOfAlias($views_path), '', $view_file);
             $file_name = pathinfo($view_file, PATHINFO_BASENAME);
             $file_code = $this->renderPartial($views_path . str_replace(array(DS, '.php'), array('.', ''), $view_file), $params, true);
             $view_file_path = MODULES_PATH . $params['module'] . DS . 'views' . $view_file;
             $view_file_dir = pathinfo($view_file_path, PATHINFO_DIRNAME);
             $child_dir = pathinfo($view_file_dir, PATHINFO_FILENAME);
             if ($child_dir == 'client') {
                 $view_file_dir = str_replace('client', lcfirst($model->class), $view_file_dir);
             } else {
                 if ($child_dir == 'admin') {
                     $view_file_dir = str_replace('admin', lcfirst($model->class) . 'Admin', $view_file_dir);
                 }
             }
             if (!is_dir($view_file_dir)) {
                 mkdir($view_file_dir, 0777, true);
                 chmod($view_file_dir, 0777);
             }
             $file_path = $view_file_dir . DS . $file_name;
             file_put_contents($file_path, $file_code);
             chmod($file_path, 0777);
         }
         $msg = "Добавьте  в метод adminMenu()  в файле " . ucfirst($params['module']) . "Module.php<br/>\r\n                   'Управление {$params['instrumental']}'    => Yii::app()->createUrl('/{$params['module']}/" . lcfirst($params['class']) . "Admin/manage'), <br/>\r\n                   'Создать {$params['accusative']}' => Yii::app()->createUrl(''/{$params['module']}/" . lcfirst($params['class']) . "Admin/create'),";
         Yii::app()->user->setFlash(Controller::MSG_SUCCESS, 'CRUD создан!');
         Yii::app()->user->setFlash(Controller::MSG_INFO, $msg);
         $this->redirect($_SERVER['REQUEST_URI']);
     }
     $this->render('create', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:55,代码来源:CrudAdminController.php

示例13: actionStep2

 public function actionStep2()
 {
     $model = new Step2();
     $form = new Form('install.Step2', $model);
     $this->performAjaxValidation($model);
     if ($form->submitted() && $model->validate()) {
         $configs = CMap::mergeArray(Yii::app()->user->getState('install_configs'), $model->getConfigs());
         Yii::app()->user->setState('install_configs', $configs);
         $step1 = Step1::loadFromSession();
         Yii::app()->setComponent('db', $step1->createDbConnection());
         //install modules
         Yii::app()->setModules($model->modules);
         //$step1->deleteDisableModules();
         //migrate
         Yii::app()->getModule('users');
         Yii::app()->executor->migrate('up --module=main');
         foreach (Yii::app()->getModules() as $id => $data) {
             if ($id == 'main') {
                 continue;
             }
             Yii::app()->getModule($id);
             if (is_dir(Yii::getPathOfAlias($id . '.migrations'))) {
                 $response = Yii::app()->executor->migrate('up --module=' . $id);
                 if (stripos($response, 'successfully') === false) {
                     echo $response;
                     die;
                 }
             }
         }
         //create admin user
         $user = new User();
         list($user->name) = explode('@', $model->admin_email);
         $user->name = ucfirst($user->name);
         $user->email = $model->admin_email;
         $user->password = UserIdentity::crypt($model->admin_pass);
         $user->status = User::STATUS_ACTIVE;
         $user->save(false);
         //set admin
         $auth = Yii::app()->authManager;
         $auth->clearAll();
         $auth->createRole('Admin');
         $auth->assign('Admin', $user->id);
         //commands collect
         Yii::app()->executor->addCommandsFromModules(Yii::app()->getModules());
         //run install method
         foreach (Yii::app()->getModules() as $id => $conf) {
             @mkdir(Yii::getPathOfAlias('webroot.upload.' . $id), 0755, true);
             Yii::app()->getModule($id)->install();
         }
         $model->saveInSession();
         //install base modules
         $this->redirect('/install.php?r=/install/install/step3');
     }
     $this->render('step2', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:55,代码来源:InstallController.php

示例14: actionUpdate

 public function actionUpdate($id, $scenario = 'update')
 {
     $model = $this->loadModel($id);
     $model->scenario = $scenario;
     $this->performAjaxValidation($model);
     $form = new Form('main.ParamForm', $model);
     if ($form->submitted() && $model->save()) {
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('update', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:11,代码来源:ParamAdminController.php

示例15: edit

 /**
  * Create or edit an user
  */
 public function edit()
 {
     $roles = array_map(function ($role) {
         return $role->getLabel();
     }, Role::getAll('id'));
     $user = User::getByUsername($this->username);
     $param = array('id' => 'user-form', 'upload' => true, 'model' => 'User', 'reference' => array('username' => $this->username), 'fieldsets' => array('general' => array('nofieldset' => true, new TextInput(array('name' => 'username', 'required' => true, 'unique' => true, 'readonly' => $user && $user->id !== App::session()->getUser()->id, 'insert' => !$user || $user->id === App::session()->getUser()->id, 'label' => Lang::get($this->_plugin . '.user-form-username-label'))), new EmailInput(array('name' => 'email', 'required' => true, 'unique' => true, 'readonly' => $user && $user->id !== App::session()->getUser()->id, 'insert' => !$user || $user->id !== App::session()->getUser()->id, 'label' => Lang::get($this->_plugin . '.user-form-email-label'))), new CheckboxInput(array('name' => 'active', 'label' => Lang::get($this->_plugin . '.user-form-active-label'))), new SelectInput(array('name' => 'roleId', 'options' => $roles, 'label' => Lang::get($this->_plugin . '.user-form-roleId-label'))), $user ? null : new PasswordInput(array('name' => 'password', 'required' => true, 'label' => Lang::get($this->_plugin . '.user-form-password-label'), 'encrypt' => array('Hawk\\Crypto', 'saltHash'))), $user ? null : new PasswordInput(array('name' => 'passagain', 'label' => Lang::get($this->_plugin . '.user-form-passagain-label'), 'required' => true, 'compare' => 'password', 'independant' => true)), new HiddenInput(array('name' => 'createTime', 'default' => time()))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new DeleteInput(array('name' => 'delete', 'value' => Lang::get('main.delete-button'), 'notDisplayed' => !($user && $user->isRemovable()))), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.lists["admin-users-list"].refresh();');
     $form = new Form($param);
     if (!$form->submitted()) {
         return View::make(Theme::getSelected()->getView("dialogbox.tpl"), array('page' => $form, 'title' => Lang::get($this->_plugin . '.user-form-title'), 'icon' => 'user'));
     } else {
         if ($form->submitted() == "delete") {
             $this->remove();
         } else {
             if ($form->check()) {
                 return $form->register();
             }
         }
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:23,代码来源:UserController.php


注:本文中的Form::submitted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。