本文整理汇总了PHP中HTML_QuickForm2::addFieldset方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2::addFieldset方法的具体用法?PHP HTML_QuickForm2::addFieldset怎么用?PHP HTML_QuickForm2::addFieldset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm2
的用法示例。
在下文中一共展示了HTML_QuickForm2::addFieldset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
require_once "HTML/QuickForm2.php";
require_once 'HTML/QuickForm2/Renderer.php';
$languages = array('' => 'Choose Language:', 'C#' => 'C#', 'JavaScript' => 'JavaScript', 'Perl' => 'Perl', 'PHP' => 'PHP');
$form = new HTML_QuickForm2('languages', 'POST');
$fieldSet = $form->addFieldset()->setLabel('Your Developer Profile');
$name = $fieldSet->addText('name')->setLabel('Your Name:');
$name->addRule('required', 'Please provide your name.');
$email = $fieldSet->addText('email')->setLabel('Your E-mail Address:');
$email->addRule('required', 'Please provide your e-mail address.');
$language = $fieldSet->addSelect('language', null, array('options' => $languages));
$language->setLabel('Choose Your Favorite Programming Language:');
$language->addRule('required', 'Please choose a programming language.');
$fieldSet->addElement('submit', null, 'Submit!');
if ($form->validate()) {
echo "<p>SUCCESS</p>";
}
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_errors' => true));
echo $form->render($renderer);
?>
示例2: 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>
示例3: array
<?php
/**
* Usage example for HTML_QuickForm2 package: repeat element
*/
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
$form = new HTML_QuickForm2('testRepeat');
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('country' => array(4, 706, 180), 'street' => array('Secret Taliban caves', 'Pirate hideout. Aaargh!', 'Somewhere in the jungle'), 'default' => array(true, false, false), 'links' => array('main' => 'yes_1', 'title' => array('php.net', 'pear.php.net', 'google.com')))));
/* @var $fsOne HTML_QuickForm2_Container_Fieldset */
$fsOne = $form->addFieldset()->setLabel('Fieldset-based repeat element');
/* @var $repeatFs HTML_QuickForm2_Container_Repeat */
$repeatFs = $fsOne->addRepeat()->setPrototype(HTML_QuickForm2_Factory::createElement('fieldset'))->setId('repeat-fieldset')->setLabel('Shipping addresses');
$countries = array('' => "-- please select --", 4 => "Afghanistan", 148 => "Chad", 180 => "Congo, Democratic Republic of", 368 => "Iraq", 706 => "Somalia", 736 => "Sudan", 716 => "Zimbabwe");
$country = $repeatFs->addSelect('country')->loadOptions($countries)->setLabel('Country:');
$repeatFs->addText('region', array('style' => 'width: 20em;'))->setLabel('Region:');
$street = $repeatFs->addText('street', array('style' => 'width: 20em;'))->setLabel('Street address:');
$repeatFs->addCheckbox('default')->setContent('default shipping address');
// button to remove a repeated item from a repeat, enabled automatically
$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