本文整理汇总了PHP中HTML_QuickForm::updateAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::updateAttributes方法的具体用法?PHP HTML_QuickForm::updateAttributes怎么用?PHP HTML_QuickForm::updateAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm
的用法示例。
在下文中一共展示了HTML_QuickForm::updateAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _customDisplay
/**
* Remplit le layer de customisation des grids.
*
* @param object $tpl instanceof Template
* @access private
* @return void
*/
private function _customDisplay($tpl)
{
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
require_once 'HTML/QuickForm/advmultiselect.php';
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form = new HTML_QuickForm('gridCustomDisplay', 'post', $_SERVER['PHP_SELF']);
$form->removeAttribute('name');
// XHTML compliance
$defaultValues = array();
// Valeurs par defaut des champs du form
$form->updateAttributes(array('onsubmit' => "return checkBeforeSubmit();"));
//$form->updateAttributes(array('onsubmit' => '$(\'customDisplayUpdated\').value=1;'));
$form->addElement('hidden', 'customDisplayUpdated', '0');
// Les plus souvent utilises
$nbItemsArray = array(30 => 30, 50 => 50, 100 => 100, 150 => 150, 200 => 200, 300 => 300, 500 => 500);
if ($this->paged) {
$defaultItemPerPage = $this->itemPerPage;
if (!in_array($defaultItemPerPage, $nbItemsArray)) {
$nbItemsArray[$defaultItemPerPage] = $defaultItemPerPage;
sort($nbItemsArray);
}
$form->addElement('select', 'customDisplayItemPerPage', _('Items number per page'), $nbItemsArray);
// ToDo: MODIFIER en fction des saisies!!
$defaultValues['customDisplayItemPerPage'] = $defaultItemPerPage;
}
$cols = array();
foreach ($this->columns as $colIndex => $column) {
// Groupement de colonnes: toDo?
// $column->groupCaption . ' ' . $column->title;
if (!$column->enabled || $column->groupCount) {
// On n'affiche que les column actives et
continue;
}
// Pour la gestion des sous-grids, on nettoie l'entete
$cols[$colIndex] = stripos($column->title, '</td><td>') !== false ? substr(str_replace('</td><td>', ', ', $column->title), 2, -2) : $column->title;
}
$labels = array(_('Columns') . ':', _('Available columns'), _('Columns to hide'));
$elt = HTML_QuickForm::createElement('advmultiselect', 'customDisplayHiddenColumns', $labels, $cols, array('style' => 'width:100%;'));
// Necessaire pour externaliser la tonne de js, si include js trouve
$js = file_exists('JS_AdvMultiSelect.php') ? '' : '{javascript}';
$jsValidation = '<script type="text/javascript">
//<![CDATA[
function checkBeforeSubmit() {
if ($(\'__customDisplayHiddenColumns\').options.length == 0) {
alert("' . _("You can't hide all columns.") . '");
return false;
}
return true;
}
//]]>
</script>';
$eltTemplate = $js . $jsValidation . '
<table{class}>
<tr><th>{label_2}</th><th> </th><th>{label_3}</th></tr>
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
';
$elt->setElementTemplate($eltTemplate);
$form->addElement($elt);
$form->addElement('submit', 'customDisplaySubmit', A_VALIDATE, 'onclick="this.form.customDisplayUpdated.value=1;"');
/*$form->addElement('button', 'customDisplaySetDefault', _('Default values'),
'onclick="fw.dom.selectOptionByValue($(\'customDisplayColumns\'), '
. JsTools::JSArray($nbItemsArray) . ');this.form.submit();"');
$(\'customDisplayUpdated\').value=1*/
$form->addElement('button', 'customDisplayCancel', A_CANCEL, 'onclick="fw.dom.toggleElement($(\'custom_display_layer\'));"');
$defaultValues['customDisplayHiddenColumns'] = $this->hiddenColumnsByUser;
$form->setDefaults($defaultValues);
// PATCH car advmultiselect buggé!!
$elt->_values = $defaultValues['customDisplayHiddenColumns'];
// end PATCH
$form->accept($renderer);
// affecte au form le renderer personnalise
$tpl->assign('form', $renderer->toArray());
}
示例2: baz_formulaire
/** baz_formulaire() - Renvoie le formulaire pour les saisies ou modification des fiches
* @param string action du formulaire :
* - soit formulaire de saisie
* - soit sauvegarde dans la base de donnees
* - soit formulaire de modification
* - soit modification de la base de donnees
* @param string url de renvois du formulaire (facultatif)
* @param array valeurs de la fiche en cas de modification (facultatif)
*
* @return string HTML
*/
function baz_formulaire($mode, $url = '', $valeurs = '')
{
$res = '';
if ($url == '') {
$lien_formulaire = $GLOBALS['_BAZAR_']['url'];
$lien_formulaire->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
//Definir le lien du formulaire en fonction du mode de formulaire choisi
if ($mode == BAZ_CHOISIR_TYPE_FICHE) {
if ($GLOBALS['params']['vue'] == BAZ_VOIR_SAISIR && isset($_REQUEST['id_typeannonce'])) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
}
}
if ($mode == BAZ_ACTION_NOUVEAU) {
if (isset($_REQUEST['id_typeannonce'])) {
if (!isset($_POST['bf_titre']) || !isset($_POST['accept_condition']) && $GLOBALS['_BAZAR_']['condition'] != null) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
}
} else {
$mode = BAZ_CHOISIR_TYPE_FICHE;
}
}
if ($mode == BAZ_ACTION_MODIFIER) {
if (!isset($_POST['bf_titre']) || !isset($_POST['accept_condition']) && $GLOBALS['_BAZAR_']['condition'] != null) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
}
$lien_formulaire->addQueryString('id_fiche', $valeurs['id_fiche']);
}
if ($mode == BAZ_ACTION_MODIFIER_V) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
$lien_formulaire->addQueryString('id_fiche', $valeurs['id_fiche']);
}
}
// contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace('/&/', '&', $url ? $url : $lien_formulaire->getURL()));
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate('<form {attributes} class="form-horizontal" novalidate="novalidate">' . "\n" . '{content}' . "\n" . '</form>' . "\n");
$squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<label class="control-label col-sm-3">' . "\n" . '<!-- BEGIN required --><span class="symbole_obligatoire">* </span><!-- END required -->' . "\n" . '{label} :</label>' . "\n" . '<div class="controls col-sm-9"> ' . "\n" . '{element}' . "\n" . '<!-- BEGIN error --><span class="alert alert-error alert-danger">{error}</span><!-- END error -->' . "\n" . '</div>' . "\n" . '</div>' . "\n");
$squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="liste_a_cocher"><strong>{label} {element}</strong>' . "\n" . '<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->' . "\n" . '</div>' . "\n" . '</div>' . "\n", 'accept_condition');
$squelette->setElementTemplate('<div class="form-actions form-group">' . "\n" . '<div class="col-sm-9 col-sm-offset-3">{label}{element}</div></div>' . "\n", 'groupe_boutons');
$squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="control-label col-sm-3">' . "\n" . '{label} :</div>' . "\n" . '<div class="controls col-sm-9"> ' . "\n" . '{element}' . "\n" . '</div>' . "\n" . '</div>', 'select');
$squelette->setRequiredNoteTemplate('<div class="col-sm-9 col-sm-offset-3 symbole_obligatoire">* {requiredNote}</div>' . "\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(_t('BAZ_CHAMPS_REQUIS'));
$formtemplate->setJsWarnings(_t('BAZ_ERREUR_SAISIE'), _t('BAZ_VEUILLEZ_CORRIGER'));
//antispam
$formtemplate->addElement('hidden', 'antispam', 0);
//------------------------------------------------------------------------------------------------
// CHOIX DU TYPE DE FICHE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_CHOISIR_TYPE_FICHE) {
if (isset($_REQUEST['id_typeannonce']) && !empty($_REQUEST['id_typeannonce'])) {
$GLOBALS['params']['idtypeannonce'] = $_REQUEST['id_typeannonce'];
$mode = BAZ_ACTION_NOUVEAU;
} else {
$resultat = array();
$tabform = baz_valeurs_tous_les_formulaires($GLOBALS['params']['categorienature'], 'html', $GLOBALS['params']['idtypeannonce']);
foreach ($tabform as $cat => $form) {
foreach ($form as $key => $value) {
$resultat[$value['bn_id_nature']] = $value;
}
}
if (count($resultat) == 0) {
$res .= '<div class="alert alert-info">' . _t('BAZ_NO_FORMS_FOUND') . '.</div>' . "\n";
} elseif (count($resultat) == 1) {
$ligne = reset($resultat);
$_REQUEST['id_typeannonce'] = $ligne['bn_id_nature'];
$GLOBALS['params']['idtypeannonce'] = $ligne['bn_id_nature'];
$mode = BAZ_ACTION_NOUVEAU;
//on remplace l'attribut action du formulaire par l'action adequate
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
$formtemplate->updateAttributes(array('action' => str_replace('&', '&', $lien_formulaire->getURL())));
} else {
$res .= '<table id="add-entry-table" class="bazar-table table table-condensed table-striped">
<thead>
<tr>
<th>' . _t('BAZ_FORMULAIRE') . '</th>
<th style="width:220px;">' . _t('BAZ_ACTIONS') . '</th>
<th>' . _t('BAZ_CATEGORIE') . '</th>
</tr>
</thead>
<tbody>' . "\n";
foreach ($resultat as $ligne) {
$newurl = $GLOBALS['wiki']->href('', $GLOBALS['wiki']->GetPageTag(), BAZ_VARIABLE_VOIR . '=' . BAZ_VOIR_SAISIR . '&' . BAZ_VARIABLE_ACTION . '=' . BAZ_ACTION_NOUVEAU . '&id_typeannonce=' . $ligne['bn_id_nature']);
//.........这里部分代码省略.........
示例3: _customDisplay
/**
* Remplit le layer de customisation des searchforms.
*
* @param object $tpl instanceof Template
* @access private
* @return void
*/
private function _customDisplay($tpl)
{
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
require_once 'HTML/QuickForm/advmultiselect.php';
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form = new HTML_QuickForm('CustomSearch', 'post', $_SERVER['PHP_SELF']);
$form->removeAttribute('name');
// XHTML compliance
$defaultValues = array();
// Valeurs par defaut des champs du form
$form->updateAttributes(array('onsubmit' => "return checkBeforeSubmit();"));
$form->addElement('hidden', 'customSearchUpdated', '0');
$criteria = array();
foreach ($this->_elementsToDisplay as $elementName => $type) {
if ($type == 'blank' || substr($type, 0, 4) == 'date') {
continue;
}
$criteria[$elementName] = $this->_form->getElement($elementName)->getLabel();
}
$labels = array(_('criteria') . ':', _('Available criteria'), _('Criteria to hide'));
$elt = HTML_QuickForm::createElement('advmultiselect', 'customSearchHiddenCriteria', $labels, $criteria, array('style' => 'width:100%;'));
// Necessaire pour externaliser la tonne de js, si include js trouve
$js = file_exists('JS_AdvMultiSelect.php') ? '' : '{javascript}';
$jsValidation = '<script type="text/javascript">
//<![CDATA[
function checkBeforeSubmit() {
if ($(\'__customSearchHiddenCriteria\').options.length == 0) {
alert("' . _("You can't hide all criteria.") . '");
return false;
}
return true;
}
//]]>
</script>';
$eltTemplate = $js . $jsValidation . '
<table{class}>
<tr><th>{label_2}</th><th> </th><th>{label_3}</th></tr>
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
';
$elt->setElementTemplate($eltTemplate);
$form->addElement($elt);
$form->addElement('submit', 'customSearchSubmit', A_VALIDATE, 'onclick="this.form.customSearchUpdated.value=1;"');
$form->addElement('button', 'customSearchCancel', A_CANCEL, 'onclick="fw.dom.toggleElement($(\'custom_search_layer\'));"');
$defaultValues['customSearchHiddenCriteria'] = $this->hiddenCriteriaByUser;
$form->setDefaults($defaultValues);
// PATCH car advmultiselect buggé!!
$elt->_values = $defaultValues['customSearchHiddenCriteria'];
// end PATCH
$form->accept($renderer);
// affecte au form le renderer personnalise
$tpl->assign('customSearchForm', $renderer->toArray());
}
示例4: array
$lightbox = false;
$mode = 1;
$inum = (int) $ini['Viewer']['inum'];
$overwritable_params = array('order', 'sort', 'field', 'keyword', 'threshold', 'compare');
// 絵文字を読み込む
require_once P2_LIB_DIR . '/emoji.inc.php';
$emj = p2_get_emoji();
$flexy->setData('e', $emj);
$flexy->setData('ak', $_conf['k_accesskey_at']);
$flexy->setData('as', $_conf['k_accesskey_st']);
// フィルタリング用フォームを表示
if (!empty($_GET['show_iv2_kfilter'])) {
!defined('P2_NO_SAVE_PACKET') && define('P2_NO_SAVE_PACKET', true);
$r = new HTML_QuickForm_Renderer_ObjectFlexy($flexy);
$qfe['keyword']->removeAttribute('size');
$qf->updateAttributes(array('method' => 'get'));
$qf->accept($r);
$qfObj = $r->toObject();
$flexy->setData('page', $page);
$flexy->setData('move', $qfObj);
P2Util::header_nocache();
$flexy->compile('iv2if.tpl.html');
$flexy->output();
exit;
} elseif (!empty($_GET['reset_filter'])) {
unset($_SESSION['iv2i_filter']);
session_write_close();
} elseif (!empty($_GET['session_no_close'])) {
foreach ($overwritable_params as $ow_key) {
if (isset(${$ow_key})) {
$_SESSION['iv2i_filter'][$ow_key] = ${$ow_key};