'number',
'url',
'email',
+ 'color',
);
/**
$attributes = '', $required = FALSE, $extra = NULL
) {
// Fudge some extra types that quickform doesn't support
+ $inputType = $type;
if ($type == 'wysiwyg' || in_array($type, self::$html5Types)) {
$attributes = ($attributes ? $attributes : array()) + array('class' => '');
$attributes['class'] = ltrim($attributes['class'] . " crm-form-$type");
CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
}
+ if ($inputType == 'color') {
+ $this->addRule($name, ts('%1 must contain a color value e.g. #ffffff.', array(1 => $label)), 'regex', '/#[0-9a-fA-F]{6}/');
+ }
+
if ($required) {
if ($type == 'file') {
$error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'uploadedfile');
$selectable->setValue(1);
}
+ $this->add('color', 'color', ts('Color'));
}
$this->assign('isTagSet', $this->_isTagSet);
parent::buildQuickForm();
}
+ public function setDefaultValues() {
+ $defaults = parent::setDefaultValues();
+ $defaults['color'] = '#ffffff';
+ return $defaults;
+ }
+
/**
* Process the form submission.
*/
</span>
</td>
</tr>
+ {if $form.color.html}
+ <tr class="crm-tag-form-block-color">
+ <td class="label">{$form.color.label}</td>
+ <td>{$form.color.html}</td>
+ </tr>
+ {/if}
<tr class="crm-tag-form-block-is_reserved">
<td class="label">{$form.is_reserved.label}</td>
<td>{$form.is_reserved.html} <br /><span class="description">{ts}Reserved tags can not be deleted. Users with 'administer reserved tags' permission can set or unset the reserved flag. You must uncheck 'Reserved' (and delete any child tags) before you can delete a tag.{/ts}