protected $_fields = array();
protected $_rgid;
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'RuleGroup';
+ }
+
/**
* Pre processing.
*
*/
public function buildQuickForm() {
$foo = CRM_Core_DAO::getAttribute('CRM_Dedupe_DAO_Rule', 'title');
-
- $this->add('text', 'title', ts('Rule Name'), array('maxlength' => 255, 'class' => 'huge'), TRUE);
+ $this->addField('title', array('label' => ts('Rule Name')), TRUE);
$this->addRule('title', ts('A duplicate matching rule with this name already exists. Please select another name.'),
'objectExists', array('CRM_Dedupe_DAO_RuleGroup', $this->_rgid, 'title')
);
- $this->addRadio('used', ts('Usage'), $this->_options, NULL, NULL, TRUE);
-
+ $this->addField('used', array('label' => ts('Usage'), 'type' => 'Radio'), TRUE);
$disabled = array();
- $reserved = $this->add('checkbox', 'is_reserved', ts('Reserved?'));
+ $reserved = $this->addField('is_reserved', array('label' => ts('Reserved?')));
if (!empty($this->_defaults['is_reserved'])) {
$reserved->freeze();
$disabled = array('disabled' => TRUE);
NULL => ts('- none -'),
) + $this->_fields, FALSE, $disabled
);
- $this->add('text', "length_$count", ts('Length'), $attributes);
- $this->add('text', "weight_$count", ts('Weight'), $attributes);
+ $this->addField('rule_length', array('entity' => 'Rule', 'name_id' => "length_$count") + $attributes);
+ $this->addField('rule_weight', array('entity' => 'Rule', 'name_id' => "weight_$count") + $attributes);
}
- $this->add('text', 'threshold', ts("Weight Threshold to Consider Contacts 'Matching':"), $attributes);
+ $this->addField('threshold', array('label' => ts("Weight Threshold to Consider Contacts 'Matching':")) + $attributes);
$this->assign('contact_type', $this->_contactType);
// Get field metadata.
$fieldSpec = civicrm_api3($props['entity'], 'getfield', $props);
$fieldSpec = $fieldSpec['values'];
-
- $label = CRM_Utils_Array::value('label', $props, $fieldSpec['title']);
+ $label = CRM_Utils_Array::value('label', $props, isset($fieldSpec['title']) ? $fieldSpec['title'] : NULL);
+ $name = isset($props['name_id']) ? $props['name_id'] : $name;
$widget = isset($props['type']) ? $props['type'] : $fieldSpec['html']['type'];
if ($widget == 'TextArea' && $props['context'] == 'search') {
unset($props['options']);
}
else {
- $options = $fieldSpec['options'];
+ $options = isset($fieldSpec['options']) ? $fieldSpec['options'] : NULL;
}
// The placeholder is only used for select-elements.
//case 'Select Date':
//TODO: Add date formats
//TODO: Add javascript template for dates.
- // case 'Radio':
+ case 'Radio':
+ $separator = isset($props['separator']) ? $props['separator'] : NULL;
+ unset($props['seperator']);
+ $this->addRadio($name, $label, $options, NULL, $separator, $required);
+ break;
+
case 'Select':
if (empty($props['multiple'])) {
$options = array('' => $props['placeholder']) + $options;
break;
//case 'AdvMulti-Select':
- //case 'CheckBox':
+ case 'CheckBox':
+ $this->add('checkbox', $name, $label, NULL, $required);
+ break;
+
case 'File':
// We should not build upload file in search mode.
if (isset($props['context']) && $props['context'] == 'search') {