本文整理汇总了PHP中HTML_QuickForm::addGroupRule方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::addGroupRule方法的具体用法?PHP HTML_QuickForm::addGroupRule怎么用?PHP HTML_QuickForm::addGroupRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm
的用法示例。
在下文中一共展示了HTML_QuickForm::addGroupRule方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// fancygroup candidates
// will be rendered in qf_fancygroup_radio
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
// will be rendered in qf_fancygroup_element
$name['first'] =& HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] =& HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
// try to validate the form
if ($form->validate()) {
$form->freeze();
}
// create a template object and load the template file
// can use either HTML_Template_Sigma or HTML_Template_ITX
$tpl =& new HTML_Template_ITX('./templates');
// $tpl =& new HTML_Template_Sigma('./templates');
$tpl->loadTemplateFile('it-dynamic.html', true, true);
// create a renderer
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
// assign elements to blocks
$renderer->setElementBlock(array('ipwdTest' => 'qf_green', 'iradYesNo' => 'qf_fancygroup', 'name' => 'qf_fancygroup'));
// Black Magic :]
$form->accept($renderer);
示例2: array
$addr['city'] =& HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array(' ', '<br />'));
// Other elements
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then freezes the data
$form->freeze();
}
示例3: addGroupRule
function addGroupRule($group, $arg1, $type = '', $format = null, $howmany = 0, $validation = 'server', $reset = false)
{
if (empty($validation) && $this->forceClientValidation) {
$validation = 'client';
}
if (is_array($arg1)) {
foreach ($arg1 as $elementIndex => $rules) {
foreach ($rules as $rule) {
if ($rule[1] == 'required') {
$this->hasRequiredFields = true;
}
}
}
}
if ($type == 'required') {
$this->hasRequiredFields = true;
}
return parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation, $reset);
}
示例4: array
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', '<br />');
// will be later assigned to style fancygroup
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
// will be later assigned to style fancygroup
$name['first'] =& HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] =& HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
// try to validate the form
if ($form->validate()) {
$form->freeze();
}
$renderer =& new HTML_QuickForm_Renderer_Object(true);
// give some elements aditional style informations
$renderer->setElementStyle(array('ipwdTest' => 'green', 'iradYesNo' => 'fancygroup', 'name' => 'fancygroup'));
$form->accept($renderer);
$options =& PEAR::getStaticProperty('HTML_Template_Flexy', 'options');
$options = array('templateDir' => './templates', 'compileDir' => './templates/build', 'debug' => 0);
$tpl =& new HTML_Template_Flexy($options);
//$tpl->compile("styles/green.html");
//$tpl->compile("styles/fancygroup.html");
// assign array with form data
示例5: getForm
function getForm()
{
if ($this->form) {
return $this->form;
}
$tilmelding = VIH_Model_KortKursus_Tilmelding::factory($this->context->name());
$tilmelding->loadBetaling();
$forsikringstekst = '';
if ($tilmelding->get('pris_forsikring') > 0) {
$forsikringstekst = ' og afbestillingsforsikring';
}
$form = new HTML_QuickForm('onlinebetaling', 'POST', $this->url());
if ($tilmelding->get('skyldig_depositum') > 0 and $tilmelding->get('dato_forfalden') > date('Y-m-d')) {
$form->addElement('header', null, 'Hvilket beløb vil du betale?');
$options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_total') . ' kroner (DKK) - dækker hele kursusprisen', $tilmelding->get('pris_total') * 100);
$options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_forudbetaling') . ' kroner (DKK) - dækker depositum' . $forsikringstekst, $tilmelding->get('pris_forudbetaling') * 100);
$form->addGroup($options, 'amount', 'Beløb', '<br />');
$form->addGroupRule('amount', 'Du skal vælge et beløb', 'required', null);
} else {
$form->addElement('header', null, 'Du skal betale nedenstående beløb');
$form->addElement('radio', 'amount', 'Beløb', $tilmelding->get('skyldig') . ' kroner (DKK) - dækker resten af beløbet', $tilmelding->get('skyldig') * 100);
$form->addRule('amount', 'Du skal vælge et beløb', 'required');
$form->addRule('amount', 'Du skal vælge et beløb', 'numeric');
$form->setDefaults(array('amount' => $tilmelding->get('skyldig') * 100));
}
$form->addElement('header', null, 'Betaling');
$form->addElement('text', 'cardnumber', 'Kortnummer');
$form->addElement('text', 'cvd', 'Sikkerhedsnummer');
$form->addElement('text', 'mm', 'Mdr.');
$form->addElement('text', 'yy', 'år');
$form->addElement('html', null, 'Vær opmærksom på, at det kan tage helt op til et minut at gennemføre transaktionen hos PBS.');
$form->addElement('submit', null, 'Betal');
$form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'required');
$form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'numeric');
$form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'required');
$form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'numeric');
$form->addRule('mm', 'Du skal udfylde Mdr.', 'required');
$form->addRule('mm', 'Du skal udfylde Mdr.', 'numeric');
$form->addRule('yy', 'Du skal udfylde år ', 'required');
$form->addRule('yy', 'Du skal udfylde år', 'numeric');
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'addslashes');
$form->applyFilter('__ALL__', 'strip_tags');
return $this->form = $form;
}
示例6: array
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th> </th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
';
$ams->setElementTemplate($template);
if (isset($_POST['fruit'])) {
$form->setDefaults(array('fruit' => $_POST['fruit']));
}
$form->addElement('submit', 'send', 'Send', array('class' => 'inputCommand'));
$form->addRule('name', 'Your name is required', 'required');
$form->addGroupRule('fruit', 'At least one fruit is required', 'required', null, 1);
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'strip_tags');
$valid = $form->validate();
$tpl = new HTML_Template_Sigma('.');
$tpl->loadTemplateFile('itdynamic.html');
$tpl->setVariable('ams_javascript', $ams->getElementJs(false));
$renderer = new HTML_QuickForm_Renderer_ITDynamic($tpl);
$form->accept($renderer);
if ($valid) {
$clean = $form->getSubmitValues();
$msg = sprintf("<p>Welcome <b>%s</b> you've selected these fruits:<br />%s</p>", $clean['name'], implode(', ', $clean['fruit']));
$tpl->setVariable('message_form_validate', $msg);
}
$tpl->show();
示例7: array
// Remove name attribute for xhtml strict compliance.
$form->removeAttribute('name');
$form->addElement('html', '<fieldset>');
$form->addElement('header', 'edit_cost', 'Edit Post Cost');
$form->addElement('text', 'cost', 'Cost:', array('size' => 5, 'maxlength' => 5, 'class' => 'inputbox'));
$radio[] = $form->createElement('radio', null, null, 'Yes', '1');
$radio[] = $form->createElement('radio', null, null, 'No', '0');
$form->addGroup($radio, 'vat_inc', 'Include Tax:');
$pl_s->loadArray($pl_opts);
$form->addElement($pl_s);
$pz_s->loadArray($pz_opts);
$form->addElement($pz_s);
$form->addElement('html', '</fieldset>');
$form->addRule('cost', 'Please enter a post cost', 'required');
$form->addRule('cost', 'post costs have to be a number', 'numeric');
$form->addGroupRule('vat_inc', 'Please choose whether to include tax or not.', 'required', null, 1);
$form->addRule('post_zone_id', 'Please select a post zone', 'nonzero');
$form->addRule('post_level_id', 'Please select a post level', 'nonzero');
if ($form->validate()) {
$form->freeze();
$values = $form->process(array(&$this, 'formValues'), false);
$menuBar['back'] = '/ushop/postage/overview';
//check then enter the record.
$res = $this->update($values, $ushop->db_name . 'post_costs', array('where' => 'post_cost_id=' . $this->registry->params['id']));
if ($res) {
$params['TYPE'] = 'pass';
$params['MESSAGE'] = '<h2>Post cost was successfully edited.</h2>';
} else {
$params['TYPE'] = 'error';
$params['MESSAGE'] = '<h2>Post cost could not be edited due to an error.</h2>';
}
示例8: checkDateOfBirth
select { margin-right: 0.5em; }
span.required { display: none; }
</style>
</head>
<body>
<h1>How many days old are you?</h1>
<?php
require_once "HTML/QuickForm.php";
require_once "HTML/QuickForm/Renderer/Tableless.php";
$form = new HTML_QuickForm("form", "get", "days_old.php", "", array("style" => "width: 30em;"), true);
$form->removeAttribute("name");
$form->setRequiredNote("");
$options = array('format' => "MdY", "minYear" => 1902, "maxYear" => date("Y"));
$form->addElement("date", "dateOfBirth", "Your date of birth", $options);
$form->addElement("submit", "calculateButton", "Calculate");
$form->addGroupRule("dateOfBirth", "Please enter your date of birth", "required");
$form->addRule("dateOfBirth", "Please enter a valid date", "callback", "checkDateOfBirth");
if ($form->isSubmitted() and $form->validate()) {
$form->process("calculateDays");
}
$renderer = new HTML_QuickForm_Renderer_Tableless();
$form->accept($renderer);
echo $renderer->toHtml();
function checkDateOfBirth($value)
{
return checkdate($value["M"], $value["d"], $value["Y"]);
}
function calculateDays($values)
{
$currentDate = mktime();
$dateOfBirth = mktime(0, 0, 0, $values["dateOfBirth"]["M"], $values["dateOfBirth"]["d"], $values["dateOfBirth"]["Y"]);
示例9: array
$form->addElement('password', 'password1', 'Set your password:', array('size' => 15, 'maxlength' => 12, 'class' => 'inputbox'));
$form->addElement('password', 'password2', 'Comfirm your password:', array('size' => 15, 'maxlength' => 12, 'class' => 'inputbox'));
// set up rules.
// name rules
// Define the rules for each element in the group
$first_name_rule_1 = array('First Name is required','required');
$first_name_rule_2 = array('Invalid First Name','minlength',3);
$last_name_rule_1 = array('Last Name is required','required');
$last_name_rule_2 = array('Invalid Last Name','maxlength',20);
// Collect together the rules for each element
$first_rules = array($first_name_rule_1, $first_name_rule_2);
$last_rules = array($last_name_rule_1, $last_name_rule_2);
// Add the rules to the group
$form->addGroupRule('name',array($first_rules, $last_rules));
// email rules
$form->addRule('email1', 'Please enter your email address', 'required');
$form->addRule('email1', 'Enter a valid email address.', 'email', null, 'server');
$form->addRule('email2', 'Please confirm your email address', 'required');
$form->addRule('email2', 'Enter a valid email address.', 'email', null, 'server');
// password rules
$form->addRule('password1', 'Please enter your password', 'required');
$form->addRule('password1', 'Enter a valid password (bewteen 8 & 12 characters long)', 'rangelength', array(8,12), 'server');
$form->addRule('password1', 'Enter a valid password (numbers, letters and ! £ $ % & / \ ( ) = ? + # - . , ; : _ only)', 'regex', '/^[a-zA-Z0-9!£$\%&\/\\\()=?+#-.,;:_]+$/', 'server');
$form->addRule('password2', 'Please comfirm your password', 'required');
$form->addRule('password2', 'Enter a valid password (bewteen 8 & 12 characters long)', 'rangelength', array(8,12), 'server');
$form->addRule('password2', 'Enter a valid password (numbers, letters and ! £ $ % & / \ ( ) = ? + # - . , ; : _ only)', 'regex', '/^[a-zA-Z0-9!£$\%&\/\\\()=?+#-.,;:_]+$/', 'server');
// compare rules
示例10: getForm
function getForm()
{
$date_options = array('minYear' => date('Y') - 10, 'maxYear' => date('Y') + 5);
if ($this->form) {
return $this->form;
}
$tilmelding = $this->getTilmelding();
foreach (VIH_Model_LangtKursus::getList('alle') as $kursus) {
$kurser[$kursus->get('id')] = $kursus->getKursusNavn();
}
$form = new HTML_QuickForm('tilmelding', 'POST', $this->url());
$form->addElement('hidden', 'id');
$form->addElement('header', null, 'Kursus');
$form->addElement('select', 'kursus_id', 'Kursus', $kurser);
$form->addElement('header', null, 'Navn og adresse');
$form->addElement('text', 'vaerelse', 'Værelse');
$form->addElement('text', 'navn', 'Navn');
$form->addElement('text', 'adresse', 'Adresse');
$form->addElement('text', 'postnr', 'Postnummer');
$form->addElement('text', 'postby', 'Postby');
$form->addElement('text', 'cpr', 'Cpr-nummer');
$form->addElement('text', 'telefonnummer', 'Telefonnummer');
$form->addElement('text', 'kommune', 'Bopælskommune');
$form->addElement('text', 'nationalitet', 'Nationalitet');
$form->addElement('text', 'email', 'E-mail');
foreach ($tilmelding->sex as $key => $value) {
$radio[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
}
$form->addGroup($radio, 'sex', 'Køn');
$form->addElement('header', null, 'Nærmeste pårørende - hvem skal vi rette henvendelse til ved sygdom');
$form->addElement('text', 'kontakt_navn', 'Navn');
$form->addElement('text', 'kontakt_adresse', 'Adresse');
$form->addElement('text', 'kontakt_postnr', 'Postnummer');
$form->addElement('text', 'kontakt_postby', 'Postby');
$form->addElement('text', 'kontakt_telefon', 'Telefon');
$form->addElement('text', 'kontakt_arbejdstelefon', 'Arbejdstelefon');
$form->addElement('text', 'kontakt_email', 'E-mail');
$form->addElement('header', null, 'Hvordan er din uddannelsesmæssige baggrund?');
foreach ($tilmelding->uddannelse as $key => $value) {
$udd[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
}
$form->addGroup($udd, 'uddannelse', 'Uddannelse');
$form->addElement('header', null, 'Hvordan betaler du?');
foreach ($tilmelding->betaling as $key => $value) {
$bet[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
}
$form->addGroup($bet, 'betaling', 'Betaling');
$form->addElement('header', null, 'Besked til Vejle Idrætshøjskole');
$form->addElement('textarea', 'besked', 'Er der andet vi bør vide?');
$form->addElement('textarea', 'tekst_diplom', 'Tekst til diplomet');
$form->addElement('header', null, 'Termin');
$form->addElement('text', 'ugeantal', 'Ugeantal');
$form->addElement('date', 'dato_start', 'Startdato', $date_options);
$form->addElement('date', 'dato_slut', 'Slutdato', $date_options);
$form->addElement('header', null, 'Priser');
$form->addElement('text', 'pris_tilmeldingsgebyr', 'Tilmeldingsgebyr');
$form->addElement('text', 'pris_uge', 'Ugepris');
$form->addElement('text', 'pris_materiale', 'Materialer');
$form->addElement('text', 'pris_rejsedepositum', 'Rejsedepositum');
$form->addElement('header', null, 'Støtte');
$form->addElement('text', 'elevstotte', 'Elevstøtte');
$form->addElement('text', 'ugeantal_elevstotte', 'Elevstøtte antal uger');
$form->addElement('text', 'kompetencestotte', 'Kompetencestøtte');
$form->addElement('text', 'statsstotte', 'Indvandrerstøtte');
$form->addElement('text', 'kommunestotte', 'Kommunestøtte');
$form->addElement('text', 'aktiveret_tillaeg', 'Aktiveret tillæg');
$form->addElement('header', null, 'Afbrudt ophold');
$form->addElement('text', 'pris_afbrudt_ophold', 'Ekstra pris');
$form->addElement('submit', null, 'Gem');
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'strip_tags');
$form->addRule('id', 'Tilmeldingen skal have et id', 'numeric');
$form->addRule('kursus_id', 'Du skal vælge et kursus', 'required');
$form->addRule('kursus_id', 'Du skal vælge et kursus', 'numeric');
$form->addRule('navn', 'Du skal skrive et navn', 'required');
$form->addRule('adresse', 'Du skal skrive en adresse', 'required');
$form->addRule('postnr', 'Postnummer', 'required');
$form->addRule('postby', 'Postby', 'required');
$form->addRule('telefonnummer', 'Telefonnummer', 'required');
$form->addRule('email', 'Du har ikke skrevet en gyldig e-mail', 'email');
$form->addRule('kommune', 'Du har ikke skrevet en kommune', 'required');
$form->addRule('nationalitet', 'Du har ikke skrevet en nationalitet', 'required');
$form->addRule('cpr', 'Du skal skrive et cpr-nummer', 'required');
$form->addRule('kontakt_navn', 'Du har ikke skrevet et gyldigt kontaktnavn', 'required');
$form->addRule('kontakt_adresse', 'Du har ikke skrevet et gyldig kontaktadresse', 'required');
$form->addRule('kontakt_postnr', 'Du har ikke skrevet en kontaktpostnummer', 'required');
$form->addRule('kontakt_postby', 'Du har ikke skrevet en kontaktpostby', 'required');
$form->addRule('kontakt_telefon', 'Du har ikke skrevet et nummer under telefon', 'required');
$form->addRule('kontakt_arbejdstelefon', 'Du har ikke skrevet et nummer under arbejdstelefon', 'required');
$form->addRule('kontakt_email', 'Du har ikke skrevet en gyldig kontakte-mail', 'email');
$form->addGroupRule('uddannelse', 'Du skal vælge din uddannelsesmæssige baggrund', 'required', null);
$form->addGroupRule('betaling', 'Du skal vælge, hvordan du betaler', 'required', null);
return $this->form = $form;
}
示例11: unset
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('form', 'post');
// fields
$form->addElement('header', 'MyHeader', 'Carga de votos por urna');
$form->addElement('hidden', 'action', 'carga');
//$form->addElement('hidden', 'params', $params_fa);
$form->addElement('select', 'new_urna', 'Urna:', $urna_select);
$form->addRule('new_urna', 'Debe especificar una urna', 'required');
$form->addElement('static', 'info', '', 'Centro Claustro');
//$form->addElement('static', 'info', '', 'Claustro');
foreach ($lista_select as $lista_id => $lista_nombre) {
unset($votos);
$votos[] =& HTML_QuickForm::createElement('text', 'votos_centro', '', $votos_attr);
$votos[] =& HTML_QuickForm::createElement('text', 'votos_claustro', '', $votos_attr);
$form->addGroup($votos, "new_lista[{$lista_id}]", $lista_nombre . ':', ' ');
$form->addGroupRule("new_lista[{$lista_id}]", 'Debe cargar los datos correctamente', 'numeric');
}
$form->addElement('static', 'info', '<div style="color:red">Por Favor, verifique los datos antes de guardar</div>', '');
$form->addElement('submit', 'btnSubmit', 'Guardar');
// rules
if (isset($_REQUEST['btnSubmit']) and $_REQUEST['btnSubmit'] == 'Guardar' and $form->validate()) {
$new_urna = $_REQUEST['new_urna'];
$new_lista = $_REQUEST['new_lista'];
foreach ($new_lista as $lista_id => $votos) {
unset($new_row);
$new_row['urna_id'] = $new_urna;
$new_row['lista_id'] = $lista_id;
if (isset($votos['votos_centro'])) {
$new_row['votos_centro'] = $votos['votos_centro'];
} else {
$new_row['votos_centro'] = 0;