本文整理汇总了PHP中Fieldset::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Fieldset::add方法的具体用法?PHP Fieldset::add怎么用?PHP Fieldset::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fieldset
的用法示例。
在下文中一共展示了Fieldset::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public static function register(Fieldset $form)
{
$form->add('email', 'E-mail:')->add_rule('required')->add_rule('valid_email');
$form->add('password', 'Choose Password:', array('type' => 'password'))->add_rule('required');
$form->add('password2', 'Re-type Password:', array('type' => 'password'))->add_rule('required');
$form->add('submit', ' ', array('type' => 'submit', 'value' => 'Register'));
return $form;
}
示例2: populate_register_fieldset
public static function populate_register_fieldset(Fieldset $form)
{
$form->add('username', 'Username:', array('class' => 'form-control'))->add_rule('required');
$form->add('password', 'Choose Password:', array('type' => 'password', 'class' => 'form-control'))->add_rule('required');
$form->add('password2', 'Re-type Password:', array('type' => 'password', 'class' => 'form-control'))->add_rule('required');
$form->add('email', 'E-mail:', array('class' => 'form-control'))->add_rule('required')->add_rule('valid_email');
$form->add('submit', ' ', array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary'));
return $form;
}
示例3: getRadioCheckbox
public function getRadioCheckbox($renderApi, $unit, $fieldId, $postRequestValue = null, $required = false)
{
$formField = new \Fieldset();
$listOptions = $this->listOptions->getListOptions($renderApi, $unit);
$inputName = strlen($renderApi->getFormValue($unit, 'inputName')) > 0 ? $renderApi->getFormValue($unit, 'inputName') . "[]" : $fieldId . "[]";
if ($listOptions->hasOptions()) {
$optionCount = 0;
$options = $listOptions->getOptions();
$optionsLength = count($options);
foreach ($options as $option) {
/* @var $option \Option */
$properties = $unit->getFormValues();
if ($properties["listType"] === \ListType::RADIO) {
$choiceField = new \RadioButtonField();
} elseif ($properties["listType"] === \ListType::CHECKBOX) {
$choiceField = new \CheckboxField();
}
$optionId = $fieldId . '_' . $optionCount;
$elementProperties = $choiceField->getElementProperties();
$elementProperties->addAttribute("value", $option->getValue());
$elementProperties->addAttribute("name", $inputName);
$elementProperties->addAttribute("id", $optionId);
// set required attribute for radio options or when there is only one checkbox
// don't set for multiple checkboxes to match server-side validation logic
if ($required && ($properties["listType"] === \ListType::RADIO || $optionsLength === 1)) {
$elementProperties->addAttribute("required", null);
}
$request = new Request();
$request->isPostRequest();
if (!$request->isPostRequest() && $option->isChecked() || !is_null($postRequestValue) && in_array($option->getValue(), $postRequestValue)) {
$elementProperties->addAttribute("checked", null);
}
$label = new \Label();
$label->add($choiceField);
$label->add(new \Span($option->getName()));
$labelProperties = $label->getElementProperties();
$labelProperties->addAttribute("for", $optionId);
$formField->add($label);
$optionCount++;
}
}
if ($this->formSubmit->isValid($renderApi, $unit) && !$this->isValidValue($unit, $postRequestValue)) {
$formField->add($this->getErrorMessage($unit, $postRequestValue));
$formField->getElementProperties()->addClass('vf__error');
}
return $formField;
}
示例4: add
/**
* Alias for $this->fieldset->add()
*/
public function add($name, $label = '', array $attributes = array(), array $rules = array())
{
return $this->fieldset->add($name, $label, $attributes, $rules);
}
示例5: viewAll
/**
* Display all options
* @return void
*/
function viewAll()
{
global $DB, $USER;
$r = $DB->config->get(array('type!' => 'not_editable'), false, false, 'section,property');
$form = new Form();
$e = $this->may($USER, EDIT);
$lastSectionName = false;
$lastSection = false;
$sections = array();
while ($c = Database::fetchAssoc($r)) {
if ($lastSectionName != $c['section']) {
$lastSectionName = $c['section'];
if ($lastSection != false && $lastSection->count() == 0) {
array_pop($sections);
}
$sections[] = $lastSection = new Fieldset(ucwords(str_replace('_', ' ', $c['section'])));
}
$mult = false;
$a = false;
switch ($c['type']) {
case 'CSV':
if (is_array($c['value'])) {
$c['value'] = @join(',', $c['value']);
}
case 'text':
if ($e) {
$a = new Input(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', $c['value'], null, __($c['description']));
} else {
$a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . $c['value'] . '</span><span class="description">' . __($c['description']) . '</span>';
}
break;
case 'password':
if ($e) {
$a = new Password(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', '********', null, __($c['description']));
} else {
$a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">********</span><span class="description">' . __($c['description']) . '</span>';
}
break;
case 'set':
$mult = true;
case 'select':
if (is_array($c['set'])) {
if ($e) {
$a = new Select(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', array_map('__', $c['set']), $c['value'], $mult, false, false, __($c['description']));
} else {
$a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . @$c['set'][$c['value']] . '</span><span class="description">' . __($c['description']) . '</span>';
}
}
break;
case 'check':
if ($e) {
$a = new Checkbox(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', $c['value'], $c['value'], false, __($c['description']));
} else {
$a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . $c['value'] . '</span><span class="description">' . __($c['description']) . '</span>';
}
break;
}
if ($a) {
$lastSection->add($a);
}
}
if ($lastSection != false && $lastSection->count() == 0) {
array_pop($sections);
}
if ($e) {
return $form->collection($sections);
} else {
return join('', $sections);
}
}
示例6: set_fieldset
/**
* @param Fieldset Fieldset to assign the field to
* @return Fieldset_Field
* @throws \RuntimeException
*/
public function set_fieldset(Fieldset $fieldset)
{
// if we currently have a fieldset
if ($this->fieldset) {
// remove the field from the fieldset
$this->fieldset->delete($this->name);
}
// add this field to the new fieldset
$fieldset->add($this);
// swap fieldsets
$this->fieldset = $fieldset;
return $this;
}