本文整理汇总了PHP中HTML_QuickForm2::addSubmit方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2::addSubmit方法的具体用法?PHP HTML_QuickForm2::addSubmit怎么用?PHP HTML_QuickForm2::addSubmit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm2
的用法示例。
在下文中一共展示了HTML_QuickForm2::addSubmit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSubmit
$valoracion_select['0'] = 'Neutra (0)';
$valoracion_select['-1'] = 'Negativa (-1)';
$valoracion_select['-2'] = 'Denuncia (-2)';
//$form_params = params_encode($params);
$form = new HTML_QuickForm2('search', 'get');
// elements
$form->addElement('hidden', 'action')->setValue($action);
$form->addElement('select', 'zona', $campo_corto)->setLabel('Zona:')->loadOptions($zona_select);
$form->addElement('select', 'provincia', $campo_medio)->setLabel('Provincia:')->loadOptions($pcia_select);
$form->addElement('text', 'medio', $campo_medio)->setLabel('Medio:');
$form->addElement('select', 'mencion')->setLabel('Mención:')->loadOptions($mencion_escala);
$form->addElement('select', 'valoracion')->setLabel('Valoración:')->loadOptions($valoracion_select);
$form->addElement('text', 'texto', $campo_largo)->setLabel('Texto:');
$form->addElement('date', 'fecha_carga_desde', $campo_corto, array('addEmptyOption' => true, 'emptyOptionText' => array('Y' => 'Anio:', 'M' => 'Mes:', 'd' => 'Dia:')))->setLabel('Fecha carga desde:');
$form->addElement('date', 'fecha_carga_hasta', $campo_corto, array('addEmptyOption' => true, 'emptyOptionText' => array('Y' => 'Anio:', 'M' => 'Mes:', 'd' => 'Dia:')))->setLabel('Fecha carga hasta:');
$submit = $form->addSubmit('btnSubmit', array('value' => 'Buscar'))->addClass(array('btn', 'btn-primary'));
////////////////////////////////////////////////////////////
// renderer fixes
function renderSubmit($renderer, $submit)
{
return '<div class="form-actions">' . $submit . '</div>';
}
require_once 'HTML/QuickForm2/Renderer.php';
$renderer = HTML_QuickForm2_Renderer::factory('callback');
$renderer->setCallbackForId($submit->getId(), 'renderSubmit');
$renderer->setOption(array('errors_prefix' => 'El formulario contiene errores:', 'required_note' => '<span class="required">*</span> denota campos requeridos'));
////////////////////////////////////////////////////////////
include_once 'header.php';
echo '<div class="page-header">';
echo ' <img class="pull-right" src="img/logo_sumar_small.png">';
echo ' <h1>Búsqueda de notas</h1>';
示例2: read_preset_form
/**
* read_preset_form generates a quickform-object to choose the announcement-preset,
* if validated redirect to announcement.php?id=new&cid=$id
*
* @param object $calendar the actual calendarentry
* @return object quickform-object to choose the preset, if validated redirect to new announcement
*/
private function read_preset_form(&$calendar)
{
// check sort or from/to
$sort = $from = $to = '';
if ($this->get('sort') !== false) {
$sort = "&sort=" . $this->get('sort');
}
if ($this->get('from') !== false) {
$from = "&from=" . $this->get('from');
}
if ($this->get('to') !== false) {
$to = "&to=" . $this->get('to');
}
// form-object
$form = new HTML_QuickForm2('choose_preset_' . $calendar->get_id(), 'post', array('name' => 'choose_preset_' . $calendar->get_id(), 'action' => 'calendar.php?id=listall' . $sort . $from . $to));
// add selectfield
$select = $form->addSelect('preset', array());
$options = array(0 => parent::lang('class.CalendarView#read_preset_form#select#choosePreset'));
$options = $options + Preset::read_all_presets('calendar');
$select->loadOptions($options);
$select->addRule('callback', parent::lang('class.CalendarView#read_preset_form#rule#select'), array($this, 'callback_check_select'));
// add submit
$submit = $form->addSubmit('submit', array('value' => parent::lang('class.CalendarView#read_preset_form#select#submit')));
// validate
if ($form->validate()) {
// get data
$data = $form->getValue();
// insert preset_id in calendar-entry
$update = array('preset_id' => $data['preset']);
$calendar->update($update);
$calendar->write_db('update');
// redirect to listall
header('Location: calendar.php?id=listall' . $sort . $from . $to);
exit;
} else {
return $form;
}
}
示例3: array
.quickform div.errors ul { margin:0; }
.quickform div.error input { border-color: #C00; background-color: #FEF; }
.quickform div.qf-checkable label,
.quickform div.qf-checkable input { display: inline; float: none; }
.quickform div.qf-checkable div,
.quickform div.qf-message { margin-left: 170px; }
.quickform div.qf-message { font-size: 88%; color: #C00; }
</style>
<title>HTML_QuickForm2 default renderer example</title>
</head>
<body>
<?php
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
$form = new HTML_QuickForm2('example');
$fs = $form->addFieldset()->setLabel('Your information');
$username = $fs->addText('username')->setLabel('Username');
$username->addRule('required', 'Username is required');
$password = $fs->addPassword('pass')->setLabel(array('Password', 'Password should be 8 characters at minimum'));
$password->addRule('required', 'Password is required');
$form->addHidden('my_hidden1')->setValue('1');
$form->addHidden('my_hidden2')->setValue('2');
$form->addSubmit('submit', array('value' => 'Send', 'id' => 'submit'));
if ($form->validate()) {
$form->toggleFrozen(true);
}
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'required_note' => '<strong>Note:</strong> Required fields are marked with an asterisk (<em>*</em>).'))->setTemplateForId('submit', '<div class="element">{element} or <a href="/">Cancel</a></div>')->setTemplateForClass('HTML_QuickForm2_Element_Input', '<div class="element<qf:error> error</qf:error>"><qf:error>{error}</qf:error>' . '<label for="{id}" class="qf-label<qf:required> required</qf:required>">{label}</label>' . '{element}' . '<qf:label_2><div class="qf-label-1">{label_2}</div></qf:label_2></div>');
echo $form->render($renderer);
?>
</body>
</html>
示例4: edit
/**
* edit edits the entry
*
* @return string html-string
*/
private function edit()
{
// smarty-templates
$sD = new JudoIntranetSmarty();
// check rights
if (Rights::check_rights($this->get('cid'), 'calendar')) {
// check cid and pid given
if ($this->get('cid') !== false && $this->get('pid') !== false) {
// check cid and pid exists
if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#edit'));
// prepare return
$return = '';
// get preset
$preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
// get fields
$fields = $preset->get_fields();
// formular
$form = new HTML_QuickForm2('edit_announcement', 'post', array('name' => 'edit_announcement', 'action' => 'announcement.php?id=edit&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
// values
$datasource = array();
foreach ($fields as $field) {
// read values
$field->read_value();
// check type
if ($field->get_type() == 'text') {
// check defaults
$datasource['calendar-' . $field->get_id()]['manual'] = '';
$datasource['calendar-' . $field->get_id()]['defaults'] = 0;
if ($field->get_value() == '') {
$datasource['calendar-' . $field->get_id()]['defaults'] = 'd' . $field->get_defaults();
} else {
$datasource['calendar-' . $field->get_id()]['manual'] = $field->get_value();
}
} elseif ($field->get_type() == 'dbhierselect') {
// explode value
list($v_first, $v_second) = explode('|', $field->get_value(), 2);
// set values
$datasource['calendar-' . $field->get_id()][0] = $v_first;
$datasource['calendar-' . $field->get_id()][1] = $v_second;
} elseif ($field->get_type() == 'dbselect') {
// check multiple
if (strpos($field->get_value(), '|') !== false) {
// separate value
$values = explode('|', $field->get_value());
foreach ($values as $i => $value) {
$datasource['calendar-' . $field->get_id()][$i] = $value;
}
} else {
$datasource['calendar-' . $field->get_id()] = $field->get_value();
}
} else {
$datasource['calendar-' . $field->get_id()] = $field->get_value();
}
}
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.AnnouncementView#entry#form#requiredNote'));
// generate field-quickform and add to form
foreach ($fields as $field) {
// generate quickform
$field_id = $field->read_quickform(array(), true);
// check $field_id
if ($field_id != '' && $field->get_type() == 'date') {
// smarty
$sD->assign('elementid', $field_id . '-0');
$sD->assign('dateFormat', 'yy-mm-dd');
$sD->assign('dateValue', $field->get_value());
$this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
}
// add to form
$form->appendChild($field->get_quickform());
}
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.AnnouncementView#edit#form#submitButton')));
// validate
if ($form->validate()) {
// get calendar
$calendar = new Calendar($this->get('cid'));
// prepare marker-array
$announcement = array('version' => date('dmy'));
// get data
$data = $form->getValue();
// insert values
foreach ($fields as $field) {
// values to db
$field->value($data[$field->get_table() . '-' . $field->get_id()]);
$field->write_db('update');
}
// add calendar-fields to array
$calendar->add_marks($announcement);
// add field-names and -values to array
$preset->add_marks($announcement);
//.........这里部分代码省略.........
示例5: take
/**
* take creates the form to take an inventoryitem from somebody else
*
* @param int $did entry-id for the inventoryitem
* @return string html-string with the form
*/
private function take($did)
{
// check rights
if (Rights::check_rights($did, 'inventory')) {
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#take'));
// get db-object
$db = Db::newDb();
// get inventory-object
$inventory = new Inventory($did);
// check owned
if ($inventory->get_owned() == 'given') {
// smarty-template
$sT = new JudoIntranetSmarty();
// prepare return
$return = '';
// get preset
$preset = $inventory->get_preset();
// get fields
$fields = $preset->get_fields();
// add headline
$sT->assign('caption', parent::lang('class.InventoryView#take#page#headline') . ': ' . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
// add take from
$movements = Inventory::movement_last_row($db, $inventory->get_id(), 'user_id', 2);
$user = new User();
$user->change_user($movements[1], false, 'id');
$sT->assign('takefrom', parent::lang('class.InventoryView#take#page#TakeFrom') . ': ' . $user->get_userinfo('name'));
// add accessory info
$sT->assign('accessoryinfo', parent::lang('class.InventoryView#take#page#accessory.required'));
// formular
$form = new HTML_QuickForm2('inventory_take', 'post', array('name' => 'inventory_take', 'action' => 'inventory.php?id=take&did=' . $this->get('did')));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.InventoryView#entry#form#requiredNote'));
// generate field-quickform and add to form
foreach ($fields as $field) {
// check if given
if ($inventory->movement_last_accessories($field) === true || $field->get_type() == 'text') {
// generate quickform
$field->read_quickform();
} else {
// generate quickform
$field->read_quickform(array('disabled' => 'disabled'));
}
// add to form
$form->appendChild($field->get_quickform());
}
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.InventoryView#take#form#submitButton')));
// validate
if ($form->validate()) {
// values
$values = $form->getValue();
// write to db
$insert_id = $this->movement_to_db('taken', $inventory->get_id(), $_SESSION['user']->userid());
// accessory to db
$this->values_to_db($insert_id, $fields, $values);
// headline
$sT->assign('action', $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ') ' . parent::lang('class.InventoryView#take#page#headline.taken'));
// accessory
$sT->assign('accessoryaction', parent::lang('class.InventoryView#take#page#accessory.taken'));
// walk through fields
$data = array();
foreach ($fields as $field) {
// check value
if (isset($values['inventory-' . $field->get_id()])) {
$field_value = $values['inventory-' . $field->get_id()];
} else {
$field_value = 0;
}
// return field and value as HTML
$field->value($field_value);
$data[] = $field->value_to_html();
}
$sT->assign('form', '');
$sT->assign('data', $data);
} else {
$sT->assign('form', $form->render($renderer));
}
// return
return $sT->fetch('smarty.inventory.takegive.tpl');
} else {
// error
$errno = $GLOBALS['Error']->error_raised('NotGivenTo', $this->get('id'), $did);
$GLOBALS['Error']->handle_error($errno);
return $GLOBALS['Error']->to_html($errno);
}
} else {
// error
$errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $did);
$GLOBALS['Error']->handle_error($errno);
return $GLOBALS['Error']->to_html($errno);
}
}
示例6: new_row
//.........这里部分代码省略.........
// check id
if ($col->name != 'id') {
// col->type
// 252 = text, 253 = varchar; 1 = tinyint(boolean); 3 = int
// add field
$field = null;
// check category
if ($col->name == 'category') {
// get options
$cat_sql = "SELECT id,name FROM category WHERE valid=1";
$cat_result = $db->query($cat_sql);
$options = array('--');
while (list($id, $name) = $cat_result->fetch_array(MYSQL_NUM)) {
$options[$id] = $name;
}
// select
$field = $form->addElement('select', $col->name, array());
$field->setLabel($translated_col . ':');
// load options
$field->loadOptions($options);
// add rules
if ($table == 'defaults') {
$field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#requiredSelect'));
$field->addRule('callback', parent::lang('class.AdministrationView#new_row#rule#checkSelect'), array($this, 'callback_check_select'));
}
} else {
// check type
if ($col->type == 252) {
// textarea
$field = $form->addElement('textarea', $col->name, array());
$field->setLabel($translated_col . ':');
// add rules
$field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
// required
if ($table == 'defaults') {
$field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
}
} elseif ($col->type == 253 || $col->type == 3) {
// input
$field = $form->addElement('text', $col->name, array());
$field->setLabel($translated_col . ':');
// add rules
$field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
// required
if ($table == 'defaults') {
$field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
}
} elseif ($col->type == 1) {
// input
$field = $form->addElement('checkbox', $col->name, array());
$field->setLabel($translated_col . ':');
}
}
}
// increment field-counter
$i++;
}
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.AdministrationView#new_row#form#submitButton')));
// validate
if ($form->validate()) {
// set output
$return .= $this->p('class="edit_caption"', parent::lang('class.AdministrationView#new_row#caption#done'));
// get data
$data = $form->getValue();
// prepare statement
$sql = "INSERT INTO {$table} ";
$sql_field = "(id,";
$sql_value = " VALUES (NULL,";
foreach ($data as $field => $value) {
// check translation
$translated_field = '';
if (parent::lang('class.AdministrationView#tableRows#name#' . $field) != "class.AdministrationView#tableRows#name#{$field} not translated") {
$translated_field = parent::lang('class.AdministrationView#tableRows#name#' . $field);
} else {
$translated_field = $field;
}
// check field
if (substr($field, 0, 5) != '_qf__' && $field != 'submit') {
// add fields to sql
$sql_field .= "{$field},";
$sql_value .= "'{$value}',";
// add fields to output
$return .= $this->p('', "{$translated_field} = '" . nl2br(htmlentities(utf8_decode($value))) . "'");
}
}
$sql_field = substr($sql_field, 0, -1) . ")";
$sql_value = substr($sql_value, 0, -1) . ")";
$sql .= $sql_field . $sql_value;
// execute
$result = $db->query($sql);
// add table content
$return .= $this->list_table_content($table, $this->get('page'));
} else {
$return .= $this->p('', parent::lang('class.AdministrationView#new_row#caption#edit'));
$return .= $form->render($renderer);
}
// return
return $return;
}
示例7: array
$repeatFs->addButton('remove', array('type' => 'button'))->setContent('remove this address')->addClass('repeatRemove');
// setting rules for repeated elements, these will work properly server-side and client-side
$country->addRule('required', 'Please select a country', null, HTML_QuickForm2_Rule::ONBLUR_CLIENT_SERVER);
$street->addRule('required', 'Please input street address', null, HTML_QuickForm2_Rule::ONBLUR_CLIENT_SERVER);
/* @var $fsTwo HTML_QuickForm2_Container_Fieldset */
$fsTwo = $form->addFieldset()->setLabel('Group-based repeat element');
/* @var $repeatGroup HTML_QuickForm2_Container_Repeat */
$repeatGroup = $fsTwo->addRepeat(null, array('id' => 'repeat-group'), array('prototype' => HTML_QuickForm2_Factory::createElement('group', 'links')->setLabel('A link:')->setSeparator(' ')))->setIndexField('links[title]')->setLabel('Links');
$repeatGroup->addText('title', array('style' => 'width: 15em;'));
// specially crafted value attribute to prevent adding index to name
$repeatGroup->addRadio('main', array('value' => 'yes_:idx:'))->setContent('main');
// button to remove a repeated item from a repeat
$repeatGroup->addButton('remove', array('type' => 'button'))->setContent('X')->addClass('repeatRemove');
// a button for adding repeated elements, with an explicit onclick
$fsTwo->addButton('add', array('type' => 'button', 'onclick' => "document.getElementById('repeat-group').repeat.add(); return false;"))->setContent('Add another link');
$form->addSubmit('submit', array('value' => 'Send this form'));
/* @var $renderer HTML_QuickForm2_Renderer_Default */
$renderer = HTML_QuickForm2_Renderer::factory('default');
// a custom template for first repeat element, a link for adding repeated
// elements there will be automatically made active due to repeatAdd class
$renderer->setTemplateForId('repeat-fieldset', <<<HTML
<div class="row repeat" id="{id}">
<qf:label><p>{label}</p></qf:label>
{content}<br />
<a class="repeatAdd" href="#">Add another address...</a>
</div>
HTML
);
/*
// Use this with the callback renderer
$renderer->setCallbackForId(
示例8: user
/**
* user controles the actions for usersettings
*
* @return string the html-string of usersettings-page
*/
private function user()
{
// smarty-template
$sUserPasswd = new JudoIntranetSmarty();
// prepare return
$return = '';
// check login
if ($_SESSION['user']->get_loggedin()) {
// smarty
$sUserPasswd->assign('pagecaption', parent::lang('class.MainView#user#caption#general') . ' ' . $_SESSION['user']->get_userinfo('name'));
// check action
if ($this->get('action') == 'passwd') {
// smarty
$sUserPasswd->assign('section', parent::lang('class.MainView#user#caption#passwd'));
// prepare form
$form = new HTML_QuickForm2('passwd', 'post', array('name' => 'passwd', 'action' => 'index.php?id=user&action=passwd'));
// add elementgroup
$passwd = $form->addElement('group', 'password', array());
// add fields
$passwd1 = $passwd->addElement('password', 'password1', array());
$passwd2 = $passwd->addElement('password', 'password2', array());
// add label
$passwd->setLabel(parent::lang('class.MainView#user#passwd#label') . ':');
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.MainView#user#passwd#submitButton')));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.MainView#user#form#requiredNote'));
// add rules
$passwd->addRule('required', parent::lang('class.MainView#user#rule#required'));
$passwd->addRule('callback', parent::lang('class.MainView#user#rule#checkPasswd'), array($this, 'callback_check_passwd'));
// validate
if ($form->validate()) {
// get values
$data = $form->getValue();
// get db-object
$db = Db::newDb();
// prepare sql-statement
$sql = "UPDATE user\n\t\t\t\t\t\t\tSET password='" . md5($data['password']['password1']) . "'\n\t\t\t\t\t\t\tWHERE id=" . $_SESSION['user']->get_id();
// execute statement
$result = $db->query($sql);
// smarty message
$sUserPasswd->assign('message', parent::lang('class.MainView#user#validate#passwdChanged'));
} else {
// smarty form and return
$sUserPasswd->assign('form', $form->render($renderer));
}
return $sUserPasswd->fetch('smarty.user.passwd.tpl');
} else {
return 'default content';
}
} else {
// not authorized
$errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
$GLOBALS['Error']->handle_error($errno);
return $GLOBALS['Error']->to_html($errno);
}
}