*
*/
function &add($type, $name, $label = '',
- $attributes = '', $required = FALSE, $javascript = NULL
+ $attributes = '', $required = FALSE, $extra = NULL
) {
- $element = $this->addElement($type, $name, $label, $attributes, $javascript);
+ // Normalize this property
+ if ($type == 'select' && is_array($extra) && !empty($extra['multiple'])) {
+ $extra['multiple'] = 'multiple';
+ }
+ $element = $this->addElement($type, $name, $label, $attributes, $extra);
if (HTML_QuickForm::isError($element)) {
CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
}
$attrs = array_merge($js, $attrs);
}
+ if ($button['type'] === 'cancel') {
+ $attrs['class'] .= ' cancel';
+ }
+
if ($button['type'] === 'reset') {
$prevnext[] = $this->createElement($button['type'], 'reset', $button['name'], $attrs);
}
$buttonName = $this->getButtonName($button['type']);
}
- if (in_array($button['type'], array(
- 'next', 'upload')) && $button['name'] === 'Save') {
+ if (in_array($button['type'], array('next', 'upload', 'done')) && $button['name'] === ts('Save')) {
$attrs = array_merge($attrs, (array('accesskey' => 'S')));
}
$prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs);
function &addRadio($name, $title, $values, $attributes = array(), $separator = NULL, $required = FALSE) {
$options = array();
$attributes = $attributes ? $attributes : array();
- $unselectable = !empty($attributes['unselectable']);
- unset($attributes['unselectable']);
+ $allowClear = !empty($attributes['allowClear']);
+ unset($attributes['allowClear']);
$attributes += array('id_suffix' => $name);
foreach ($values as $key => $var) {
$options[] = $this->createElement('radio', NULL, NULL, $var, $key, $attributes);
if ($required) {
$this->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required');
}
- if ($unselectable) {
- $group->setAttribute('unselectable', TRUE);
+ if ($allowClear) {
+ $group->setAttribute('allowClear', TRUE);
}
return $group;
}
- function addYesNo($id, $title, $unselectable = FALSE, $required = NULL, $attributes = array()) {
+ function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $attributes = array()) {
$attributes += array('id_suffix' => $id);
$choice = array();
$choice[] = $this->createElement('radio', NULL, '11', ts('Yes'), '1', $attributes);
$choice[] = $this->createElement('radio', NULL, '11', ts('No'), '0', $attributes);
$group = $this->addGroup($choice, $id, $title);
- if ($unselectable) {
- $group->setAttribute('unselectable', TRUE);
+ if ($allowClear) {
+ $group->setAttribute('allowClear', TRUE);
}
if ($required) {
$this->addRule($id, ts('%1 is a required field.', array(1 => $title)), 'required');
* - field (field name - only needed if different from name used on the form)
* - option_url - path to edit this option list - usually retrieved automatically - set to NULL to disable link
* - placeholder - set to NULL to disable
+ * - multiple - bool
* @param bool $required
* @throws CRM_Core_Exception
* @return HTML_QuickForm_Element
* - create - can the user create a new entity on-the-fly?
* Set to TRUE if entity is contact and you want the default profiles,
* or pass in your own set of links. @see CRM_Core_BAO_UFGroup::getCreateLinks for format
- * - api - array of settings for the getlist api
+ * note that permissions are checked automatically
+ * - api - array of settings for the getlist api wrapper
+ * note that it accepts a 'params' setting which will be passed to the underlying api
* - placeholder - string
* - multiple - bool
* - class, etc. - other html properties