本文整理汇总了PHP中Form::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::render方法的具体用法?PHP Form::render怎么用?PHP Form::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: render
public function render()
{
if ($uid = $this->modx->getLoginUserID('web')) {
$this->redirect('exitTo');
$this->renderTpl = $this->getCFGDef('skipTpl', $this->lexicon->getMsg('register.default_skipTpl'));
}
return parent::render();
}
示例4: render
public function render()
{
if (is_null($this->userdata)) {
$this->redirect('exitTo');
$this->renderTpl = $this->getCFGDef('skipTpl', $this->lexicon->getMsg('profile.default_skipTpl'));
}
return parent::render();
}
示例5: 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));
}
示例6: getForm
public function getForm($type, $action, $request, $isPost = false, $errors = array())
{
$form = new Form($id = 'form-picture', $name = 'form-picture', $action, 'POST', 'form-horizontal', $isPost);
$form->addField('id', Lang::_('Picture Id'), 'text', $this->_getfieldvalue('id', $type, $request), true, '', @$errors['id']);
$form->addField('quarter_id', Lang::_('Quarter id'), 'text', $this->_getfieldvalue('quarter_id', $type, $request), false, '', @$errors['quarter_id']);
$form->addField('src', Lang::_('Src'), 'file', $this->_getfieldvalue('src', $type, $request), false, '', @$errors['src']);
$form->addField('info_id', Lang::_('Info id'), 'text', $this->_getfieldvalue('info_id', $type, $request), true, '', @$errors['info_id']);
$form->addField('user_id', Lang::_('User id'), 'text', $this->_getfieldvalue('user_id', $type, $request), true, '', @$errors['user_id']);
return $form->render();
}
示例7: render
/**
* Main method called by the controller.
*
* @param array $gp The current GET/POST parameters
* @param array $errors In this class the second param is used to pass information about the email mode (HTML|PLAIN)
* @return string content
*/
public function render($gp, $errors)
{
$this->currentMailSettings = $errors;
$content = '';
if ($this->subparts['template']) {
$this->settings = $this->globals->getSettings();
$content = parent::render($gp, []);
}
return $content;
}
示例8: render
public function render()
{
// render("begin") or render("end")
$args = func_get_args();
if ($args) {
parent::render($args[0]);
return;
}
$this->getTemplate()->_form = $this->getTemplate()->form = $this;
$this->getTemplate()->render();
}
示例9: render
public function render(\Zend_View_Interface $view = null)
{
/** @var \Zend_Form_Element $element */
foreach ($this->getElements() as $element) {
$label = $element->getLabel();
if (!empty($label)) {
$element->setAttrib('placeholder', $label);
}
}
return parent::render($view);
}
示例10: getForm
public function getForm($type, $action, $request, $isPost = false, $errors = array())
{
$form = new Form($id = 'form-comment', $name = 'form-comment', $action, 'POST', 'form-horizontal', $isPost);
$form->addField('id', Lang::_('Id'), 'text', $this->_getfieldvalue('id', $type, $request), true, '', @$errors['id']);
$form->addField('user_id', Lang::_('User Id'), 'text', $this->_getfieldvalue('user_id', $type, $request), true, '', @$errors['user_id']);
$form->addField('quarter_id', Lang::_('Quarter Id'), 'text', $this->_getfieldvalue('quarter_id', $type, $request), false, '', @$errors['quarter_id']);
$form->addField('info_id', Lang::_('Info Id'), 'text', $this->_getfieldvalue('info_id', $type, $request), false, '', @$errors['info_id']);
$form->addField('content', Lang::_('Content'), 'text-area', $this->_getfieldvalue('content', $type, $request), true, '', @$errors['content']);
$form->addField('photo_id', Lang::_('Photo Id'), 'file', $this->_getfieldvalue('photo_id', $type, $request), false);
return $form->render();
}
示例11: 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));
}
示例12: 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();
}
示例13: admin_action
/**
* Панель управления
*/
public function admin_action()
{
$form = new Form("Wysiwyg/forms/config");
$options = new Core_ArrayObject();
$options->type = config('wysiwyg.editor');
$form->type->setValues(self::$editors);
$form->object($options);
if ($result = $form->result()) {
if (isset(self::$editors[$result['type']])) {
cogear()->set('wysiwyg.editor', $result['type']);
success(t('Конфигурация успешно сохранена.'));
}
}
append('content', $form->render());
}
示例14: admin
/**
* Control Panel
*/
public function admin()
{
$form = new Form("Wysiwyg.config");
$options = new Core_ArrayObject();
$options->editor = config('wysiwyg.editor');
$form->init();
$form->elements->type->setValues(self::$editors);
$form->object($options);
if ($result = $form->result()) {
if (isset(self::$editors[$result['type']])) {
cogear()->set('wysiwyg.editor', $result['type']);
success('Configuration saved successfully.');
}
}
append('content', $form->render());
}
示例15: action_edit
public function action_edit()
{
$id = $this->request->param('id');
if (!User::current('is_admin') && !(Group::current('item_create') && !$id) && !(Group::current('item_edit') && $id)) {
throw new HTTP_Exception_403('Forbidden');
}
$uoms = DB::select()->from('uoms')->execute()->as_array('id', 'name');
$form = new Form('items/edit' . ($id ? '/' . $id : ''));
$form->add("sku", 'SKU/Barcode', Form::STRING, '', array('not_empty'))->add("name", 'Description', Form::STRING, '', array('not_empty'))->add("uom", 'UOM', Form::SELECT, array(0 => 'Not selected') + $uoms, array('not_empty'))->add("cost", 'Cost (each)', Form::NUMBER, '', array('not_empty'))->add("qty", 'Qty Tracked', Form::BOOL);
if ($id) {
$item = DB::select()->from('items')->where('id', '=', $id)->execute()->current();
} else {
$item = array();
}
$form->values($item);
$error = false;
if ($_POST) {
$item = $form->filter($_POST);
$error = $form->validate($item);
if (!$error) {
if ($id) {
DB::update('items')->set($item)->where('id', '=', $id)->execute();
} else {
$result = DB::insert('items', array_keys($item))->values(array_values($item))->execute();
$id = Arr::get($result, 0);
}
$item['id'] = $id;
$item['success'] = true;
if ($this->request->is_ajax()) {
$item['uom'] = Arr::get($uoms, Arr::get($item, 'uom', 0), 'Unknown');
header('Content-type: application/json');
die(json_encode($item));
}
Messages::save('Item successfully saved!', 'success');
$this->redirect('/items');
} 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));
}