$type, $name, $label = '',
$attributes = '', $required = FALSE, $extra = NULL
) {
+ if ($type == 'wysiwyg') {
+ $attributes = ($attributes ? $attributes : array()) + array('class' => '');
+ $attributes['class'] .= ' crm-form-wysiwyg';
+ $type = "textarea";
+ }
if ($type == 'select' && is_array($extra)) {
// Normalize this property
if (!empty($extra['multiple'])) {
}
// call the form hook
- // also call the hook function so any modules can set thier own custom defaults
+ // also call the hook function so any modules can set their own custom defaults
// the user can do both the form and set default values with this hook
CRM_Utils_Hook::buildForm(get_class($this), $this);
*
* @param string $title
* The title of the form.
- *
- * @return void
*/
public function setTitle($title) {
$this->_title = $title;
}
+ /**
+ * Assign billing type id to bltID.
+ *
+ * @throws CRM_Core_Exception
+ */
+ public function assignBillingType() {
+ $this->_bltID = CRM_Core_BAO_Location::getBillingLocationId();
+ $this->set('bltID', $this->_bltID);
+ $this->assign('bltID', $this->_bltID);
+ }
+
/**
* Setter function for options.
*
'Select Country',
'Multi-Select Country',
'AdvMulti-Select',
- 'CheckBox',
+ 'CheckBoxGroup',
+ 'RadioGroup',
'Radio',
)));
}
$props += CRM_Utils_Array::value('html', $fieldSpec, array());
CRM_Utils_Array::remove($props, 'entity', 'name', 'context', 'label', 'action', 'type');
- // TODO: refactor switch statement, to seperate methods.
+ // TODO: refactor switch statement, to separate methods.
switch ($widget) {
case 'Text':
case 'Link':
//TODO: Autodetect ranges
+ $props['size'] = isset($props['size']) ? $props['size'] : 60;
$this->add('text', $name, $label, $props, $required);
break;
case 'hidden':
- $this->add('hidden', $name, $label, $props, $required);
+ $this->add('hidden', $name, NULL, $props, $required);
+ break;
+
+ case 'TextArea':
+ //Set default columns and rows for textarea.
+ $props['rows'] = isset($props['rows']) ? $props['rows'] : 4;
+ $props['cols'] = isset($props['cols']) ? $props['cols'] : 60;
+ $this->addElement('textarea', $name, $label, $props, $required);
+ break;
+
+ case 'Select Date':
+ //TODO: add range support
+ //TODO: Add date formats
+ //TODO: Add javascript template for dates.
+ $this->addDate($name, $label, $required, $props);
break;
- //case 'TextArea':
- //case 'Select Date':
- //TODO: Add date formats
- //TODO: Add javascript template for dates.
case 'Radio':
$separator = isset($props['separator']) ? $props['separator'] : NULL;
unset($props['separator']);
// TODO: Add and/or option for fields that store multiple values
break;
+ case 'CheckBoxGroup':
+ $this->addCheckBox($name, $label, array_flip($options), $required, $props);
+ break;
+
+ case 'RadioGroup':
+ $this->addRadio($name, $label, $options, $props, NULL, $required);
+ break;
+
//case 'AdvMulti-Select':
case 'CheckBox':
- $this->add('checkbox', $name, $label, NULL, $required);
+ $text = isset($props['text']) ? $props['text'] : NULL;
+ unset($props['text']);
+ $this->addElement('checkbox', $name, $label, $text, $props);
break;
case 'File':
));
}
- /**
- * @param string $name
- * @param $label
- * @param $attributes
- * @param bool $forceTextarea
- */
- public function addWysiwyg($name, $label, $attributes, $forceTextarea = FALSE) {
- // 1. Get configuration option for editor (tinymce, ckeditor, pure textarea)
- // 2. Based on the option, initialise proper editor
- $editorID = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'editor_id'
- );
- $editor = strtolower(CRM_Utils_Array::value($editorID,
- CRM_Core_OptionGroup::values('wysiwyg_editor')
- ));
- if (!$editor || $forceTextarea) {
- $editor = 'textarea';
- }
- if ($editor == 'joomla default editor') {
- $editor = 'joomlaeditor';
- }
-
- if ($editor == 'drupal default editor') {
- $editor = 'drupalwysiwyg';
- }
-
- //lets add the editor as a attribute
- $attributes['editor'] = $editor;
-
- $this->addElement($editor, $name, $label, $attributes);
- $this->assign('editor', $editor);
-
- // include wysiwyg editor js files
- // FIXME: This code does not make any sense
- $includeWysiwygEditor = FALSE;
- $includeWysiwygEditor = $this->get('includeWysiwygEditor');
- if (!$includeWysiwygEditor) {
- $includeWysiwygEditor = TRUE;
- $this->set('includeWysiwygEditor', $includeWysiwygEditor);
- }
-
- $this->assign('includeWysiwygEditor', $includeWysiwygEditor);
- }
-
/**
* @param int $id
* @param $title
// from that page
// we don't really need to set it when $tempID is set because the params have that stored
$this->set('cid', 0);
- return $tempID;
+ return (int) $tempID;
}
$userID = $this->getLoggedInUserContactID();
- if ($tempID == $userID) {
- return $userID;
+ if (!is_null($tempID) && $tempID === $userID) {
+ return (int) $userID;
}
//check if this is a checksum authentication
return $tempID;
}
- return $userID;
+ return is_numeric($userID) ? $userID : NULL;
}
/**