本文整理汇总了PHP中Horde_Form::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Form::isValid方法的具体用法?PHP Horde_Form::isValid怎么用?PHP Horde_Form::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Form
的用法示例。
在下文中一共展示了Horde_Form::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _content
protected function _content()
{
$vars = Horde_Variables::getDefaultVariables();
$formname = $vars->get('formname');
$done = false;
$form = new Horde_Form($vars);
$fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($this->_params['form_id']);
foreach ($fields as $field) {
/* In case of these types get array from stringlist. */
if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') {
$field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']);
}
/* Setup the field with all the parameters. */
$form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']);
}
if ($formname) {
$form->validate($vars);
if ($form->isValid() && $formname) {
$form->getInfo($vars, $info);
$info['form_id'] = $this->_params['form_id'];
try {
$submit = $GLOBALS['ulaform_driver']->submitForm($info);
$GLOBALS['notification']->push(_("Form submitted successfully."), 'horde.success');
$done = true;
} catch (Horde_Exception $e) {
$GLOBALS['notification']->push(sprintf(_("Error submitting form. %s."), $e->getMessage()), 'horde.error');
}
}
}
/* Render active or inactive, depending if submitted or
* not. */
$render_type = $done ? 'renderInactive' : 'renderActive';
/* Render the form. */
$renderer = new Horde_Form_Renderer();
$renderer->showHeader(false);
Horde::startBuffer();
$form->{$render_type}($renderer, $vars, Horde::selfUrl(true), 'post');
return Horde::endBuffer();
}
示例2: isset
$readonly = isset($field['readonly']) ? $field['readonly'] : null;
$desc = isset($field['desc']) ? $field['desc'] : null;
$field_params = isset($field['params']) ? $field['params'] : array();
$addForm->addVariable($field['label'], 'extra[' . $field_name . ']', $field['type'], $field['required'], $readonly, $desc, $field_params);
}
}
} catch (Horde_Exception_HookNotSet $e) {
}
if (empty($extra)) {
$addForm->addVariable(_("Username"), 'user_name', 'text', true);
$addForm->addVariable(_("Password"), 'password', 'passwordconfirm', false, false, _("type the password twice to confirm"));
}
switch ($vars->form) {
case 'add':
$addForm->validate($vars);
if ($addForm->isValid() && $vars->get('formname') == 'adduser') {
$addForm->getInfo($vars, $info);
if (empty($info['user_name']) && isset($info['extra']['user_name'])) {
$info['user_name'] = $info['extra']['user_name'];
}
if (empty($info['password']) && isset($info['extra']['password'])) {
$info['password'] = $info['extra']['password'];
}
if (empty($info['user_name'])) {
$notification->push(_("You must specify the username to add."), 'horde.error');
} elseif ($auth->exists($info['user_name'])) {
$notification->push(sprintf(_("The user \"%s\" already exists."), $info['user_name']), 'horde.error');
} else {
$credentials = array('password' => $info['password']);
if (isset($info['extra'])) {
foreach ($info['extra'] as $field => $value) {
示例3: isset
$param['desc'] = isset($param['desc']) ? $param['desc'] : null;
$param['params'] = isset($param['params']) ? $param['params'] : null;
$form->addVariable($param['label'], 'form_params[' . $id . ']', $param['type'], $param['required'], $param['readonly'], $param['desc'], $param['params']);
}
}
/* Set default language for the form. */
$v = $form->addVariable(_("Default language"), 'form_params[language]', 'enum', false, false, null, array($registry->nlsconfig->languages, _("-- default configured --")));
$v->setOption('htmlchars', true);
/* TODO: set up Ulaform to insert any javascript saved here into the form. */
$v = $form->addVariable(_("Javascript to execute on form \"submit\":"), 'form_onsubmit', 'longtext', false, false, null, array(3, 40));
$v->setHelp('on-submit');
/* Set up the action choice fields. */
$vars->set('old_form_action', $form_action);
if ($formname && !$changed_action) {
$form->validate($vars);
if ($form->isValid()) {
$form->getInfo($vars, $info);
try {
$form_id = $ulaform_driver->saveForm($info);
$notification->push(_("Form details saved."), 'horde.success');
Horde::url('forms.php', true)->redirect();
} catch (Ulaform_Exception $e) {
$notification->push(sprintf(_("Error saving form. %s."), $e->getMessage()), 'horde.error');
}
}
}
/* Render the form. */
$view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES));
Horde::startBuffer();
$form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('edit.php'), 'post');
$view->main = Horde::endBuffer();
示例4: array
Horde_Registry::appInit('ulaform', array('admin' => true));
$delvars = Horde_Variables::getDefaultVariables();
$form_id = $delvars->get('form_id');
$form_submit = $delvars->get('submitbutton');
/* Set up the forms. */
$ulaform_driver = $injector->getInstance('Ulaform_Factory_Driver')->create();
$viewvars = new Horde_Variables($ulaform_driver->getForm($form_id));
$viewform = new Horde_Form($viewvars, _("Form Details"));
$delform = new Horde_Form($delvars, _("Delete this form?"));
$viewform->addVariable(_("Name"), 'form_name', 'text', false);
$viewform->addVariable(_("Action"), 'form_action', 'email', false);
$delform->setButtons(array(_("Delete"), _("Do not delete")));
$delform->addHidden('', 'form_id', 'int', true);
if ($form_submit == _("Delete")) {
$delform->validate($delvars);
if ($delform->isValid()) {
$delform->getInfo($delvars, $info);
try {
$deleteform = $ulaform_driver->deleteForm($info['form_id']);
$notification->push(_("Form deleted."), 'horde.success');
Horde::url('forms.php', true)->redirect();
} catch (Ulaform_Exception $e) {
$notification->push(sprintf(_("Error deleting form. %s."), $e->getMessage()), 'horde.error');
}
}
} elseif (!empty($form_submit)) {
$notification->push(_("Form has not been deleted."), 'horde.message');
Horde::url('forms.php', true)->redirect();
}
/* Render the form. */
$renderer = new Horde_Form_Renderer();
示例5: catch
$vars = new Horde_Variables($vars);
} else {
$notification->push(_("No field specified."), 'horde.warning');
Horde::url('fields.php', true)->add('form_id', $vars->get('form_id'))->redirect();
}
}
/* Set up the form. */
$fieldform = new Horde_Form($vars, _("Delete Field"));
$fieldform->setButtons(array(_("Delete"), _("Do not delete")));
$fieldform->addHidden('', 'field_id', 'int', true);
$fieldform->addHidden('', 'form_id', 'int', true);
$fieldform->addHidden('', 'field_name', 'text', false);
$fieldform->addVariable(_("Delete this field?"), 'field_name', 'text', false, true);
if ($vars->get('submitbutton') == _("Delete")) {
$fieldform->validate($vars);
if ($fieldform->isValid()) {
$fieldform->getInfo($vars, $info);
try {
$del_field = $injector->getInstance('Ulaform_Factory_Driver')->create()->deleteField($info['field_id']);
$notification->push(sprintf(_("Field \"%s\" deleted."), $info['field_name']), 'horde.success');
Horde::url('fields.php', true)->add('form_id', $info['form_id'])->redirect();
} catch (Ulaform_Exception $e) {
$notification->push(sprintf(_("Error deleting field. %s."), $e->getMessage()), 'horde.error');
}
}
} elseif ($vars->get('submitbutton') == _("Do not delete")) {
$notification->push(_("Field not deleted."), 'horde.message');
Horde::url('fields.php', true)->add('form_id', $vars->get('form_id'))->redirect();
}
/* Render the form. */
$view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES));
示例6: array
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ulaform', array('admin' => true));
/* Get some variables. */
$vars = Horde_Variables::getDefaultVariables();
$form_id = $vars->get('form_id');
$formname = $vars->get('formname');
$fields = $ulaform_driver->getFieldsArray($form_id);
/* Set up the form object. */
$sortform = new Horde_Form($vars, _("Sort Fields"));
/* Set up the form. */
$sortform->setButtons(_("Save"));
$sortform->addVariable(_("Select the sort order of the fields"), 'field_order', 'sorter', false, false, null, array($fields, 12));
$sortform->addHidden('', 'form_id', 'int', true);
if ($formname) {
$sortform->validate($vars);
if ($sortform->isValid()) {
$sortform->getInfo($vars, $info);
try {
$sort = $injector->getInstance('Ulaform_Factory_Driver')->create()->sortFields($info);
$notification->push(_("Field sort order saved."), 'horde.success');
Horde::url('fields.php', true)->add('form_id', $form_id)->redirect();
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("Error saving fields. %s."), $e->getMessage()), 'horde.error');
}
}
}
/* Render the form. */
$view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES));
Horde::startBuffer();
$sortform->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('sortfields.php'), 'post');
$view->main = Horde::endBuffer();