parent::buildQuickForm();
// FIXME: This 'onDuplicate' form element is never used -- copy/paste error?
- $duplicateOptions = [];
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL
- );
-
- $this->addGroup($duplicateOptions, 'onDuplicate',
- ts('On duplicate entries')
- );
+ $this->addRadio('onDuplicate', ts('On duplicate entries'), [
+ CRM_Import_Parser::DUPLICATE_SKIP => ts('Skip'),
+ CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update'),
+ CRM_Import_Parser::DUPLICATE_FILL => ts('Fill'),
+ ]);
}
/**
$form->addSearchFieldMetadata(['Contact' => self::getFilteredSearchFieldMetadata('demographic')]);
$form->addFormFieldsFromMetadata();
// radio button for gender
- $genderOptions = [];
+ $genderOptionsAttributes = [];
$gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
foreach ($gender as $key => $var) {
- $genderOptions[$key] = $form->createElement('radio', NULL,
- ts('Gender'), $var, $key,
- ['id' => "civicrm_gender_{$var}_{$key}"]
- );
+ $genderOptionsAttributes[$key] = ['id' => "civicrm_gender_{$var}_{$key}"];
}
- $form->addGroup($genderOptions, 'gender_id', ts('Gender'))->setAttribute('allowClear', TRUE);
+ $form->addRadio('gender_id', ts('Gender'), $gender, ['allowClear' => TRUE], NULL, FALSE, $genderOptionsAttributes);
$form->add('number', 'age_low', ts('Min Age'), ['class' => 'four', 'min' => 0]);
$form->addRule('age_low', ts('Please enter a positive integer'), 'positiveInteger');
);
// duplicate handling options
- $duplicateOptions = [];
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK
- );
-
- $this->addGroup($duplicateOptions, 'onDuplicate',
- ts('For Duplicate Contacts')
- );
+ $this->addRadio('onDuplicate', ts('For Duplicate Contacts'), [
+ CRM_Import_Parser::DUPLICATE_SKIP => ts('Skip'),
+ CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update'),
+ CRM_Import_Parser::DUPLICATE_FILL => ts('Fill'),
+ CRM_Import_Parser::DUPLICATE_NOCHECK => ts('No Duplicate Checking'),
+ ]);
$mappingArray = CRM_Core_BAO_Mapping::getMappings('Import Contact');
$js = ['onClick' => "buildSubTypes();buildDedupeRules();"];
// contact types option
- $contactOptions = [];
+ $contactTypeOptions = $contactTypeAttributes = [];
if (CRM_Contact_BAO_ContactType::isActive('Individual')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL, $js
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_INDIVIDUAL] = ts('Individual');
+ $contactTypeAttributes[CRM_Import_Parser::CONTACT_INDIVIDUAL] = $js;
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD, $js
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_HOUSEHOLD] = ts('Household');
+ $contactTypeAttributes[CRM_Import_Parser::CONTACT_HOUSEHOLD] = $js;
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION, $js
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_ORGANIZATION] = ts('Organization');
+ $contactTypeAttributes[CRM_Import_Parser::CONTACT_ORGANIZATION] = $js;
}
-
- $this->addGroup($contactOptions, 'contactType',
- ts('Contact Type')
- );
+ $this->addRadio('contactType', ts('Contact Type'), $contactTypeOptions, [], NULL, FALSE, $contactTypeAttributes);
$this->addElement('select', 'subType', ts('Subtype'));
$this->addElement('select', 'dedupe', ts('Dedupe Rule'));
$this->buildQuickEntityForm();
// Determine if we can cancel recurring contribution via API with this processor
if ($this->_paymentProcessorObj->supports('CancelRecurringNotifyOptional')) {
- $searchRange = [];
- $searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1');
- $searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0');
-
- $this->addGroup(
- $searchRange,
- 'send_cancel_request',
- ts('Send cancellation request to %1 ?',
- [1 => $this->_paymentProcessorObj->getTitle()])
- );
+ $this->addRadio('send_cancel_request', ts('Send cancellation request to %1 ?', [1 => $this->_paymentProcessorObj->getTitle()]), [ts('No'), ts('Yes')]);
}
else {
$this->assign('cancelRecurNotSupportedText', $this->_paymentProcessorObj->getText('cancelRecurNotSupportedText', []));
['onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"]
);
$extraOption = ['onclick' => "return pcpAnonymous( );"];
- $elements = [];
- $elements[] = &$this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
- $elements[] = &$this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
- $this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
+ $this->addRadio('pcp_is_anonymous', NULL, [ts('Include my name and message'), ts('List my contribution anonymously')], [], ' ', FALSE, [$extraOption, $extraOption]);
$this->add('text', 'pcp_roll_nickname', ts('Name'), ['maxlength' => 30]);
$this->addField('pcp_personal_note', ['entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;']);
$this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities);
- $options = [];
- $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1);
- $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2);
- $this->addGroup($options, 'is_for_organization', '');
+ $this->addRadio('is_for_organization', '', [1 => ts('Optional'), 2 => ts('Required')]);
$this->add('textarea', 'for_organization', ts('On behalf of Label'), ['rows' => 2, 'cols' => 50]);
// collect goal amount
parent::buildQuickForm();
$duplicateOptions = [];
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Insert new contributions'), CRM_Import_Parser::DUPLICATE_SKIP
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Update existing contributions'), CRM_Import_Parser::DUPLICATE_UPDATE
- );
- $this->addGroup($duplicateOptions, 'onDuplicate',
- ts('Import mode')
- );
+ $this->addRadio('onDuplicate', ts('Import mode'), [
+ CRM_Import_Parser::DUPLICATE_SKIP => ts('Insert new contributions'),
+ CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update existing contributions'),
+ ]);
$this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
// Add and/or option for fields that store multiple values
if ($search && self::isSerialized($field)) {
-
- $operators = [
- $qf->createElement('radio', NULL, '', ts('Any'), 'or', ['title' => ts('Results may contain any of the selected options')]),
- $qf->createElement('radio', NULL, '', ts('All'), 'and', ['title' => ts('Results must have all of the selected options')]),
- ];
- $qf->addGroup($operators, $elementName . '_operator');
+ $qf->addRadio($elementName . '_operator', '', [
+ 'or' => ts('Any'),
+ 'and' => ts('All'),
+ ], [], NULL, FALSE, [
+ 'or' => ['title' => ts('Results may contain any of the selected options')],
+ 'and' => ['title' => ts('Results must have all of the selected options')],
+ ]);
$qf->setDefaults([$elementName . '_operator' => 'or']);
}
}
elseif (in_array($fieldName, ['gender_id', 'communication_style_id'])) {
$options = [];
$pseudoValues = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $fieldName);
- foreach ($pseudoValues as $key => $var) {
- $options[$key] = $form->createElement('radio', NULL, ts($title), $var, $key);
- }
- $group = $form->addGroup($options, $name, $title);
- if ($required) {
- $form->addRule($name, ts('%1 is a required field.', [1 => $title]), 'required');
- }
- else {
- $group->setAttribute('allowClear', TRUE);
- }
+ $form->addRadio($name, ts('%1', [1 => $title]), $pseudoValues, ['allowClear' => !$required], NULL, $required);
}
elseif ($fieldName === 'prefix_id' || $fieldName === 'suffix_id') {
$form->addSelect($name, [
$dateText = ts('yyyy-mm-dd OR yyyymmdd (1998-12-25 OR 19981225) OR (2008-9-1 OR 20080901)');
}
- $dateOptions[] = $form->createElement('radio', NULL, NULL, $dateText, self::DATE_yyyy_mm_dd);
-
- $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('mm/dd/yy OR mm-dd-yy (12/25/98 OR 12-25-98) OR (9/1/08 OR 9-1-08)'), self::DATE_mm_dd_yy);
- $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('mm/dd/yyyy OR mm-dd-yyyy (12/25/1998 OR 12-25-1998) OR (9/1/2008 OR 9-1-2008)'), self::DATE_mm_dd_yyyy);
- $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('Month dd, yyyy (December 12, 1998)'), self::DATE_Month_dd_yyyy);
- $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd-mon-yy OR dd/mm/yy (25-Dec-98 OR 25/12/98)'), self::DATE_dd_mon_yy);
- $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd/mm/yyyy (25/12/1998) OR (1/9/2008)'), self::DATE_dd_mm_yyyy);
- $form->addGroup($dateOptions, 'dateFormats', ts('Date Format'), '<br/>');
+ $form->addRadio('dateFormats', ts('Date Format'), [
+ self::DATE_yyyy_mm_dd => $dateText,
+ self::DATE_mm_dd_yy => ts('mm/dd/yy OR mm-dd-yy (12/25/98 OR 12-25-98) OR (9/1/08 OR 9-1-08)'),
+ self::DATE_mm_dd_yyyy => ts('mm/dd/yyyy OR mm-dd-yyyy (12/25/1998 OR 12-25-1998) OR (9/1/2008 OR 9-1-2008)'),
+ self::DATE_Month_dd_yyyy => ts('Month dd, yyyy (December 12, 1998)'),
+ self::DATE_dd_mon_yy => ts('dd-mon-yy OR dd/mm/yy (25-Dec-98 OR 25/12/98)'),
+ self::DATE_dd_mm_yyyy => ts('dd/mm/yyyy (25/12/1998) OR (1/9/2008)'),
+ ], [], '<br/>');
$form->setDefaults(['dateFormats' => self::DATE_yyyy_mm_dd]);
}
);
// is searchable by range?
- $searchRange = [];
- $searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1');
- $searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0');
-
- $this->addGroup($searchRange, 'is_search_range', ts('Search by Range?'));
+ $this->addRadio('is_search_range', ts('Search by Range?'), [ts('No'), ts('Yes')]);
// add buttons
$this->addButtons([
parent::buildQuickForm();
$duplicateOptions = [];
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK
- );
- $this->addGroup($duplicateOptions, 'onDuplicate',
- ts('On Duplicate Entries')
- );
-
+ $this->addRadio('onDuplicate', ts('On Duplicate Entries'), [
+ CRM_Import_Parser::DUPLICATE_SKIP => ts('Skip'),
+ CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update'),
+ CRM_Import_Parser::DUPLICATE_NOCHECK => ts('No Duplicate Checking'),
+ ]);
$this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
$this->addContactTypeSelector();
*/
protected function addContactTypeSelector() {
//contact types option
- $contactOptions = [];
+ $contactTypeOptions = [];
if (CRM_Contact_BAO_ContactType::isActive('Individual')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_INDIVIDUAL] = ts('Individual');
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_HOUSEHOLD] = ts('Household');
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
- $contactOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION
- );
+ $contactTypeOptions[CRM_Import_Parser::CONTACT_ORGANIZATION] = ts('Organization');
}
-
- $this->addGroup($contactOptions, 'contactType',
- ts('Contact Type')
- );
+ $this->addRadio('contactType', ts('Contact Type'), $contactTypeOptions);
$this->setDefaults([
'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL,
public function buildQuickForm() {
parent::buildQuickForm();
- $duplicateOptions = [];
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Insert new Membership'), CRM_Import_Parser::DUPLICATE_SKIP
- );
- $duplicateOptions[] = $this->createElement('radio',
- NULL, NULL, ts('Update existing Membership'), CRM_Import_Parser::DUPLICATE_UPDATE
- );
-
- $this->addGroup($duplicateOptions, 'onDuplicate',
- ts('Import mode')
- );
+ $this->addRadio('onDuplicate', ts('Import mode'), [
+ CRM_Import_Parser::DUPLICATE_SKIP => ts('Insert new Membership'),
+ CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update existing Membership'),
+ ]);
$this->setDefaults([
'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP,
]);
['onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"]
);
$extraOption = ['onclick' => "return pcpAnonymous( );"];
- $elements = [];
- $elements[] = &$page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
- $elements[] = &$page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
- $page->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
+ $page->addRadio('pcp_is_anonymous', '', [ts('Include my name and message'), ts('List my support anonymously')], [], ' ', FALSE, [$extraOption, $extraOption]);
$page->_defaults['pcp_is_anonymous'] = 0;
$page->add('text', 'pcp_roll_nickname', ts('Name'), ['maxlength' => 30]);
// on page refresh.
$this->setAttribute('autocomplete', 'off');
- $sendOptions = [
- $this->createElement('radio', NULL, NULL, ts('Send immediately'), 'send_immediate', ['id' => 'send_immediate', 'style' => 'margin-bottom: 10px;']),
- $this->createElement('radio', NULL, NULL, ts('Send at:'), 'send_later', ['id' => 'send_later']),
- ];
- $this->addGroup($sendOptions, 'send_option', '', '<br>');
+ $this->addRadio('send_option', '', [
+ 'send_immediate' => ts('Send immediately'),
+ 'send_later' => ts('Send at:'),
+ ], [], '<br>', FALSE, [
+ 'send_immediate' => ['id' => 'send_immediate', 'style' => 'margin-bottom: 10px;'],
+ 'send_later' => ['id' => 'send_later'],
+ ]);
$this->add('datepicker', 'start_date', '', NULL, FALSE, ['minDate' => time()]);
$form->addElement('checkbox', 'is_map', ts('Enable mapping for this profile?'));
// should we allow updates on a exisitng contact
- $options = [];
- $options[] = $form->createElement('radio', NULL, NULL, ts('Issue warning and do not save'), 0);
- $options[] = $form->createElement('radio', NULL, NULL, ts('Update the matching contact'), 1);
- $options[] = $form->createElement('radio', NULL, NULL, ts('Allow duplicate contact to be created'), 2);
-
- $form->addGroup($options, 'is_update_dupe', ts('What to do upon duplicate match'));
+ $form->addRadio('is_update_dupe', ts('What to do upon duplicate match'), [ts('Issue warning and do not save'), ts('Update the matching contact'), ts('Allow duplicate contact to be created')]);
// we do not have any url checks to allow relative urls
$form->addElement('text', 'post_URL', ts('Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'post_URL'));
$form->_cmsId = TRUE;
}
- $options = [];
- $options[] = $form->createElement('radio', NULL, NULL, ts('No account create option'), 0);
- $options[] = $form->createElement('radio', NULL, NULL, ts('Give option, but not required'), 1);
- $options[] = $form->createElement('radio', NULL, NULL, ts('Account creation required'), 2);
-
- $form->addGroup($options, 'is_cms_user', ts('%1 user account registration option?', [1 => $config->userFramework]));
+ $form->addRadio('is_cms_user', ts('%1 user account registration option?', [1 => $config->userFramework]), [ts('No account create option'), ts('Give option, but not required'), ts('Account creation required')]);
// options for including Proximity Search in the profile search form
- $proxOptions = [];
- $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('None'), 0);
- $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Optional'), 1);
- $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Required'), 2);
-
- $form->addGroup($proxOptions, 'is_proximity_search', ts('Proximity Search'));
+ $form->addRadio('is_proximity_search', ts('Proximity Search'), [ts('None'), ts('Optional'), ts('Required')]);
}
}