public function renderOptions($options, fxFormElementSet &$e, fxForm &$f, $parent = '') { $html5 = $f->_target === 'html5'; $o = array(); if ('' != $parent) { $parent .= '-'; } if (!empty($options)) { foreach ($options as $k => $v) { if (is_array($v)) { $o[] = '<optgroup label="' . htmlspecialchars($k) . '">'; $o[] = $this->renderOptions($v, $e, $f, $parent . fxForm::_simplify($k)); if (!$html5) { $o[] = "</optgroup>"; } } else { $selected = in_array($parent . fxForm::_simplify($k), $e->_value) ? ' selected' : ''; $o[] = "<option{$selected} value=\"" . $parent . fxForm::_simplify($k) . "\">" . htmlspecialchars($v) . "</option>"; } } } return implode("\n", $o); }
public function __construct($name, $label, $members) { fxAssert::isArray($members, 'members') && fxAssert::isNotEmpty($members, 'members'); parent::__construct($name, $label); $this->_members = $members; $this->id = $tmp = fxForm::_simplify($name); $this->name = $tmp . '[]'; $this->_mmap = self::makeMemberMap($members); }
/** ==================== Form submission handler follows ==================== * * A success handler for the form. * * Make sure the form's ->onSuccess() method is uncommented and pointing * here for it to get called **/ function mySuccessHandler(fxForm &$form) { return "<h3>Thank you {$form->getValueOf('Name')}, your message has been sent.</h3>"; }
public function makeId(fxFormElement &$e, $parent_id, $make_attr = true) { $id = fxForm::_simplify($parent_id . '-' . $e->id); if ($make_attr && '' !== $id) { $id = 'id="' . $id . '"'; } // Conditionally prepare it as an attribute. return $id; }