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


PHP Form::add方法代码示例

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


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

示例1: _createForgotPassForm

 public function _createForgotPassForm()
 {
     $form = new Form();
     $form->action = "/forgotpass";
     $form->add(EmailField::name('email')->label('Email')->help('What is your email address?')->required(true));
     return $form;
 }
开发者ID:JoonasMelin,项目名称:BotQueue,代码行数:7,代码来源:auth.php

示例2: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id');
     $form = new Form('security/groups/edit' . ($id ? '/' . $id : ''));
     $form->add("name", 'Name', Form::STRING, '', array('not_empty'))->add('is_admin', 'Administrative group', Form::BOOL)->add('show_all_jobs', 'Show all jobs (unchecked - show only assigned jobs)', Form::BOOL)->add('allow_assign', 'Allow assigning jobs', Form::BOOL)->add('allow_reports', 'Allow tracking changes', Form::BOOL)->add('allow_submissions', 'Allow tracking submissions', Form::BOOL)->add('allow_finance', 'Financial reports', Form::BOOL)->add('allow_forms', 'Forms submission', Form::BOOL)->add('allow_custom_forms', 'Custom forms submission', Form::BOOL)->add('edit_custom_forms', 'Edit custom forms reports', Form::BOOL)->add('time_machine', 'Time Machine', Form::BOOL);
     $form->add('columns', 'Show columns in job search', Form::INFO);
     foreach (Columns::$fixed as $key => $value) {
         $form->add($key, $value, Form::BOOL);
     }
     $item = $id ? Group::get($id) : array();
     if ($item) {
         $columns = explode(',', $item['columns']);
         foreach ($columns as $column) {
             $item[$column] = 1;
         }
         unset($item['columns']);
     }
     $form->values($item);
     if ($_POST) {
         $value = $form->filter($_POST);
         if ($value['is_admin']) {
             $value['show_all_jobs'] = 1;
             $value['allow_assign'] = 1;
             $value['allow_reports'] = 1;
             $value['allow_submissions'] = 1;
             $value['allow_finance'] = 1;
             $value['allow_forms'] = 0;
             $value['allow_custom_forms'] = 1;
             $value['edit_custom_forms'] = 1;
             $value['time_machine'] = 1;
             $value['columns'] = implode(',', array_keys(Columns::$fixed));
         } else {
             $columns = array();
             foreach (Columns::$fixed as $key => $name) {
                 if (Arr::get($value, $key)) {
                     $columns[] = $key;
                 }
             }
             $value['columns'] = implode(',', $columns);
         }
         $value = array_diff_key($value, Columns::$fixed);
         if (!$form->validate($value)) {
             if ($id) {
                 DB::update('groups')->set($value)->where('id', '=', $id)->execute();
             } else {
                 $origin = Arr::get($_POST, 'permissions');
                 unset($_POST['permissions']);
                 $id = Arr::get(DB::insert('groups', array_keys($value))->values(array_values($value))->execute(), 0);
                 DB::query(Database::INSERT, DB::expr("INSERT INTO `group_columns` (`group_id`, `column_id`, `permissions`) \n                        (SELECT :id, `column_id`, `permissions` FROM `group_columns` WHERE `group_id` = :origin)")->param(':id', $id)->param(':origin', $origin)->compile())->execute();
             }
             Messages::save('Group successfully saved!', 'success');
             $this->redirect('/security/groups');
         }
     }
     if (!$id) {
         $groups = DB::select('id', 'name')->from('groups')->execute()->as_array('id', 'name');
         $form->add('permissions', 'Copy permissions from group', Form::SELECT, $groups);
     }
     $this->response->body($form->render());
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:60,代码来源:Groups.php

示例3: action_edit

 public function action_edit()
 {
     $type = $this->request->param('id');
     $id = Arr::get($_GET, 'id');
     $uoms = DB::select('id', 'name')->from('uoms')->execute()->as_array('id', 'name');
     $form = new Form('items/edit/' . $type . '?id=' . ($id ?: ''));
     $form->add('code', 'Code', Form::STRING, '', array('not_empty'))->add('name', 'Name', Form::STRING, '', array('not_empty'));
     if ($type == 'item') {
         $table = 'items';
         $form->add('descr', 'Description', Form::TEXT);
     } else {
         $table = 'bom_items';
     }
     $form->add('uom', 'UOM', Form::SELECT, array(0 => 'Not selected') + $uoms);
     $item = DB::select()->from($table)->where('id', '=', $id)->execute()->current();
     $form->values($item);
     if ($_POST) {
         $value = $form->filter($_POST);
         if (!$form->validate($value)) {
             if ($id) {
                 DB::update($table)->set($value)->where('id', '=', $id)->execute();
             } else {
                 $id = Arr::get(DB::insert($table, array_keys($value))->values(array_values($value))->execute(), 0, 0);
             }
             $value['id'] = $id;
             $value['success'] = true;
             $value['uom'] = Arr::get($uoms, $value['uom'], 'Unknown');
             if (isset($value['descr'])) {
                 $value['descr'] = nl2br($value['descr']);
             }
             die(json_encode($value));
         }
     }
     $this->response->body($form->render());
 }
开发者ID:Alex-AG,项目名称:exeltek-mima,代码行数:35,代码来源:Items.php

示例4: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id');
     $groups = DB::select()->from('groups')->execute()->as_array('id', 'name');
     $companies = DB::select()->from('companies')->execute()->as_array('id', 'name');
     $form = new Form('users/edit' . ($id ? '/' . $id : ''));
     $form->add("login", 'Login', Form::STRING, '', array('not_empty', 'min_length' => array(':value', 4)))->add('name', 'Real Name', Form::STRING)->add('group_id', 'Group', Form::SELECT, array(0 => 'Not selected') + $groups, array('not_empty'))->add('company_id', 'Company', Form::SELECT, array(0 => 'Not selected') + $companies, array('not_empty'))->add("email", 'E-Mail', Form::STRING, '', array('not_empty', 'email'))->add('is_admin', 'Admin', Form::BOOL);
     $form->add('passw', 'Password', Form::PASSWORD, '', $id ? false : array('not_empty', 'min_length' => array(':value', 6)))->add('pass2', 'Confirm password', Form::PASSWORD, '', array('matches' => array(':validation', 'pass2', 'passw')));
     $item = $id ? User::get($id) : array();
     $form->values($item);
     $error = false;
     if ($_POST) {
         $item = $form->filter($_POST);
         $error = $form->validate($item);
         if (!$error) {
             unset($item['pass2']);
             $exists = DB::select('id')->from('users')->where_open()->where('login', '=', $item['login'])->or_where('email', '=', $item['email'])->where_close()->and_where('id', '<>', $id)->execute()->get('id');
             if ($exists) {
                 if ($this->request->is_ajax()) {
                     $item['success'] = false;
                     $item['error'] = 'exists';
                     header('Content-type: application/json');
                     die(json_encode($item));
                 }
                 Messages::save("User with given login or email already exists! Please, enter different login/email!");
             } else {
                 if ($id) {
                     if (!Arr::get($item, 'passw')) {
                         unset($item['passw']);
                     }
                     DB::update('users')->set($item)->where('id', '=', $id)->execute();
                 } else {
                     $result = DB::insert('users', array_keys($item))->values(array_values($item))->execute();
                     $id = Arr::get($result, 0);
                 }
                 $item['id'] = $id;
                 $item['success'] = true;
                 $item['group'] = Arr::get($groups, $item['group_id'], 'Unknown');
                 $item['company'] = Arr::get($companies, $item['company_id'], 'Unknown');
                 if ($this->request->is_ajax()) {
                     header('Content-type: application/json');
                     die(json_encode($item));
                 }
                 Messages::save('User successfully saved!', 'success');
                 $this->redirect('/users');
             }
         } elseif ($this->request->is_ajax()) {
             $item['success'] = false;
             $item['error'] = $error;
             header('Content-type: application/json');
             die(json_encode($item));
         }
         $form->values($item);
     }
     $this->response->body($form->render($error));
 }
开发者ID:Alex-AG,项目名称:exeltek-mima,代码行数:56,代码来源:Users.php

示例5: Form

 function _createAddCommentForm($content_id, $content_type)
 {
     $form = new Form();
     $form->action = "/comment/add";
     $form->submitText = "Add Comment";
     $form->add(HiddenField::name('content_id')->value($content_id));
     $form->add(HiddenField::name('content_type')->value($content_type));
     $form->add(TextareaField::name('comment')->required(true)->width('50%')->rows(3));
     return $form;
 }
开发者ID:JoonasMelin,项目名称:BotQueue,代码行数:10,代码来源:comment.php

示例6: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id');
     $form = new Form('security/users/edit' . ($id ? '/' . $id : ''));
     $groups = DB::select('id', 'name')->from('groups')->execute()->as_array('id', 'name');
     $partners = DB::select('id', 'name')->from('companies')->execute()->as_array('id', 'name');
     $regions = DB::select('id', 'name')->from('regions')->execute()->as_array('id', 'name');
     $form->add("login", 'Login', Form::STRING, '', array('not_empty', 'min_length' => array(':value', 4)))->add("email", 'E-Mail', Form::STRING, '', array('not_empty', 'email'))->add('group_id', 'Group', Form::SELECT, array('' => 'Please select...') + $groups, array('not_empty'), array('class' => 'multiselect'))->add('company_id', 'Partner', Form::SELECT, array('' => 'None') + $partners, null, array('class' => 'multiselect'))->add('default_region', 'Default region', Form::SELECT, array(0 => 'None') + $regions, null, array('class' => 'multiselect'));
     $form->add('region[]', 'Available regions', Form::SELECT, $regions, null, array('multiple' => 'multiple', 'class' => 'multiselect'));
     $form->add('passw', 'Password', Form::PASSWORD, '', $id ? false : array('not_empty', 'min_length' => array(':value', 6)))->add('pass2', 'Confirm password', Form::PASSWORD, '', array('matches' => array(':validation', 'pass2', 'passw')));
     $item = $id ? User::get($id) : array();
     if ($id) {
         $item['region[]'] = DB::select('region_id')->from('user_regions')->where('user_id', '=', $id)->execute()->as_array(NULL, 'region_id') ?: false;
     }
     $form->values($item);
     $error = false;
     if ($_POST) {
         $item = $form->filter($_POST);
         if (!$form->validate($item)) {
             unset($item['pass2']);
             $exists = DB::select('id')->from('users')->where_open()->where('login', '=', $item['login'])->or_where('email', '=', $item['email'])->where_close()->and_where('id', '<>', $id)->execute()->get('id');
             if ($exists) {
                 Messages::save("User with given login or email already exists! Please, enter different login/email!");
             } else {
                 $regs = Arr::get($_POST, 'region');
                 if ($id) {
                     if (!Arr::get($item, 'passw')) {
                         unset($item['passw']);
                     }
                     DB::update('users')->set($item)->where('id', '=', $id)->execute();
                     DB::delete('user_regions')->where('user_id', '=', $id)->execute();
                 } else {
                     $result = DB::insert('users', array_keys($item))->values(array_values($item))->execute();
                     $id = Arr::get($result, 0);
                 }
                 if ($regs) {
                     $result = DB::insert('user_regions', array('user_id', 'region_id'));
                     foreach ($regs as $reg) {
                         $result->values(array($id, $reg));
                     }
                     $result->execute();
                 }
                 Messages::save('User successfully saved!', 'success');
                 $this->redirect('/security/users');
             }
         }
         $form->values($item);
     }
     $this->response->body($form->render($error));
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:50,代码来源:Users.php

示例7: roles

 public function roles($params)
 {
     //Load necessary models
     $usersModel = Model::load("auth.users");
     $usersRolesModel = Model::load("auth.users_roles");
     $rolesModel = Model::load("auth.roles");
     //required queries
     $user = $usersModel->getWithField("user_id", $params[0]);
     $usersRoles = $usersRolesModel->getWithField("user_id", $params[0]);
     $loggedInUsersRoles = $usersRolesModel->getWithField("user_id", $_SESSION['user_id']);
     $roles = $rolesModel->get();
     $this->label = "Select Role(s) for " . $user[0]['first_name'] . " " . $user[0]['last_name'];
     //create a new form
     $form = new Form();
     $form->setRenderer("table");
     $fieldset = Element::create('ColumnContainer', 3);
     $form->add($fieldset);
     foreach ($roles as $role) {
         if ($role['role_id'] == 1) {
             //Boolean to determine if the outer foreach loop should "continue" particular loop or not
             $continueBool = false;
             //Loop through all the current user's
             foreach ($loggedInUsersRoles as $userRole) {
                 if ($userRole['role_id'] == 1) {
                     $continueBool = false;
                     break;
                 } else {
                     $continueBool = true;
                 }
             }
             if ($continueBool) {
                 continue;
             }
         }
         $checkbox = Element::create("Checkbox", $role['role_name'], self::underscore($role['role_name']), "", $role['role_id']);
         foreach ($usersRoles as $userRole) {
             if ($userRole['role_id'] == $role['role_id']) {
                 $checkbox->setValue($role['role_id']);
             }
         }
         $fieldset->add($checkbox);
     }
     $userIdHiddenField = Element::create("HiddenField", "user_id", $params[0]);
     $form->add($userIdHiddenField);
     $form->setValidatorCallback("{$this->getClassName()}::roles_callback");
     $form->setShowClear(false);
     //render the form
     return $form->render();
 }
开发者ID:nthc,项目名称:cfx,代码行数:49,代码来源:CfxAuthUsersController.php

示例8: getNetworkSettingsMask

 function getNetworkSettingsMask()
 {
     $tbl = new Table(array("", ""));
     $rIp = $tbl->createRow();
     $rIp->setAttribute(0, new Text("IP:"));
     $rIp->setAttribute(1, new Textfield("ip", $this->getLocalIp()));
     $tbl->addRow($rIp);
     $rMask = $tbl->createRow();
     $rMask->setAttribute(0, new Text("Subnet-Mask:"));
     $rMask->setAttribute(1, new Textfield("mask", $this->getLocalMask()));
     $tbl->addRow($rMask);
     $rGate = $tbl->createRow();
     $rGate->setAttribute(0, new Text("Gateway:"));
     $rGate->setAttribute(1, new Textfield("gate", $this->getLocalGate()));
     $tbl->addRow($rGate);
     $rDns = $tbl->createRow();
     $rDns->setAttribute(0, new Text("DNS-Server:"));
     $rDns->setAttribute(1, new Textfield("dns", $this->getLocalDns()));
     $tbl->addRow($rDns);
     $rOk = $tbl->createRow();
     $rOk->setSpawnAll(true);
     $rOk->setAttribute(0, new Button("saveNetworkSettingsMask", $this->SAVE_BTN_LABEL));
     $tbl->addRow($rOk);
     $f = new Form();
     $f->add($tbl);
     return $f;
 }
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:27,代码来源:NetworksettingsEditor.php

示例9: testFormElementsMoves

 public function testFormElementsMoves()
 {
     $this->assertTrue(is_array($this->object->elements()));
     $this->assertFalse($this->object->has('test'));
     $element = new Elements\Text('test');
     $element2 = new Elements\Text('test2');
     $this->object->add($element);
     $this->object->add($element2);
     $this->assertTrue($this->object->has('test'));
     $this->assertEquals($element, $this->object->element('test'));
     $this->object->remove('test');
     $this->assertFalse($this->object->has('test'));
     $this->assertEquals(1, count($this->object->elements()));
     $this->object->addAll(array(new Elements\Text('test2'), new Elements\Text('test3')));
     $this->setExpectedException('Fwk\\Form\\Exceptions\\UnknownElementException');
     $this->object->element('nonExistant');
 }
开发者ID:fwk,项目名称:form,代码行数:17,代码来源:FormTest.php

示例10: showFullname

 function showFullname()
 {
     $fp = new Text($this->getPath(), 3, true);
     $btnDel = new Button("clearLog", "Log leeren");
     $hdnDel = new Hiddenfield("clearLogFile", $this->FULLPATH);
     $frmDel = new Form();
     $tblTtl = new Table(array("", ""));
     $tblTtl->setColSizes(array(null, 100));
     $tblTtl->setAlignments(array("left", "right"));
     $rTtl = $tblTtl->createRow();
     $rTtl->setAttribute(0, $fp);
     $rTtl->setAttribute(1, $btnDel);
     $tblTtl->addRow($rTtl);
     $frmDel->add($tblTtl);
     $frmDel->add($hdnDel);
     $frmDel->show();
 }
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:17,代码来源:LogFile.php

示例11: appendToForm

 /**
  * @param FormBuilder|Form $builder
  */
 public function appendToForm(&$builder, $data, $formArea)
 {
     if ($formArea == 'features') {
         $name = strtolower($this->getName());
         if ($this->factory->serviceExists('mautic.form.type.cloudstorage.' . $name)) {
             $builder->add('provider', 'cloudstorage_' . $name, ['label' => 'mautic.integration.form.provider.settings', 'required' => false, 'data' => isset($data['provider']) ? $data['provider'] : []]);
         }
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:12,代码来源:CloudStorageIntegration.php

示例12: getContents

 /**
  * The default page which shows the login form.
  * @see lib/controllers/Controller#getContents()
  */
 public function getContents()
 {
     Application::addStylesheet("css/login.css");
     Application::$template = "login.tpl";
     Application::setTitle("Login");
     if ($_SESSION["logged_in"]) {
         Application::redirect(Application::getLink("/"));
     }
     $form = new Form();
     $form->setRenderer("default");
     $username = new TextField("Username", "username");
     $form->add($username);
     $password = new PasswordField("Password", "password");
     $form->add($password);
     $form->setSubmitValue("Login");
     $form->setCallback("{$this->getClassName()}::callback", $this);
     return $form->render();
 }
开发者ID:ekowabaka,项目名称:wyf,代码行数:22,代码来源:SystemLoginController.php

示例13: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id');
     $form = new Form('groups/edit' . ($id ? '/' . $id : ''));
     $form->add("name", 'Name', Form::STRING, '', array('not_empty'));
     $roles = DB::select()->from('roles')->execute()->as_array('id', 'name');
     foreach ($roles as $key => $role) {
         $form->add($key, $role, Form::BOOL);
     }
     $item = $id ? Group::get($id) : array();
     $form->values($item);
     if ($_POST) {
         $value = $form->filter($_POST);
         if (!$form->validate($value)) {
             Database::instance()->begin();
             if ($id) {
                 DB::update('groups')->set(array('name' => $value['name']))->where('id', '=', $id)->execute();
                 DB::delete('group_roles')->where('group_id', '=', $id)->execute();
             } else {
                 $id = Arr::get(DB::insert('groups', array('name'))->values(array($value['name']))->execute(), 0);
             }
             $list = array();
             foreach ($roles as $key => $role) {
                 if (Arr::get($_POST, $key)) {
                     $list[] = array($id, $key);
                 }
             }
             if ($list) {
                 $query = DB::insert('group_roles', array('group_id', 'role_id'));
                 foreach ($list as $role) {
                     $query->values($role);
                 }
                 $query->execute();
             }
             Database::instance()->commit();
             $value['id'] = $id;
             $value['success'] = true;
             die(json_encode($value));
             //Messages::save('Group successfully saved!', 'success');
             //$this->redirect('/groups');
         }
     }
     $this->response->body($form->render());
 }
开发者ID:Alex-AG,项目名称:exeltek-po,代码行数:44,代码来源:Groups.php

示例14: renderContent

 /**
  * @param RenderAPI  $renderApi
  * @param Unit       $unit
  * @param ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $formSend = false;
     $this->http = new \Request();
     $form = new \Form();
     $honeyPotComponent = new \HoneyPotComponent();
     $this->formSubmit = new \FormSubmit();
     $postRequest = $this->formSubmit->getPostValues();
     $elementProperties = $form->getElementProperties();
     $elementProperties->setId("form" . str_replace("-", "", $unit->getId()));
     $elementProperties->addAttribute('action', $_SERVER['REQUEST_URI'] . '#' . $unit->getId());
     $elementProperties->addAttribute('method', 'post');
     $elementProperties->addAttribute('enctype', 'multipart/form-data');
     $form->add($honeyPotComponent->getHoneyPot());
     $form->add($honeyPotComponent->getFormUnitIdentifier($unit->getId()));
     if ($this->formSubmit->isValid($renderApi, $unit) && count($postRequest) > 0 && $honeyPotComponent->isValidHoneyPot($postRequest) && $this->hasValidFormData($renderApi, $unit)) {
         $this->formSubmit->setFieldLabelsToFormValueSet($renderApi);
         try {
             $this->sentEmail($renderApi, $unit, $postRequest);
             $formSend = true;
         } catch (\Exception $e) {
             $errorText = new \Span();
             $errorText->setContent("Unable to send email:<br />" . $e->getMessage());
             $errorContainer = new \Container();
             $errorContainer->add($errorText);
             $errorContainer->getElementProperties()->addClass('vf__main_error');
             $form->add($errorContainer);
         }
     }
     if ($formSend) {
         $confirmationText = new \Span();
         $confirmationText->setContent(preg_replace('/\\n/', '<br>', $renderApi->getFormValue($unit, 'confirmationText')));
         $confirmationContainer = new \Container();
         $confirmationContainer->add($confirmationText);
         $confirmationContainer->getElementProperties()->addClass('confirmationText');
         $form->add($confirmationContainer);
         echo $form->renderElement();
     } else {
         echo $form->renderElementProgressive($renderApi, $unit);
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:46,代码来源:rz_form.php

示例15: testIsValid

 /**
  * Test validate
  */
 public function testIsValid()
 {
     $this->form->add('<div>Test</div>');
     $element_valid = $this->getMockBuilder('Jasny\\FormBuilder\\Element')->getMockForAbstractClass();
     $element_valid->expects($this->exactly(2))->method('isValid')->will($this->returnValue(true));
     $element_invalid = $this->getMockBuilder('Jasny\\FormBuilder\\Element')->getMockForAbstractClass();
     $element_invalid->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $this->form->add($element_valid);
     $this->assertTrue($this->form->isValid());
     $this->form->add($element_invalid);
     $this->assertFalse($this->form->isValid());
 }
开发者ID:sachsy,项目名称:formbuilder,代码行数:15,代码来源:FormTest.php


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