$chekFlag = $id;
}
- $checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
+ $checkBoxes[$id] = NULL;
}
- $this->addGroup($checkBoxes, 'contact_check');
+ $group = $this->addRadio('contact_check', NULL, $checkBoxes);
+ $groupElements = $group->getElements();
if ($chekFlag) {
- $checkBoxes[$chekFlag]->setChecked(TRUE);
+ foreach ($groupElements as $groupElement) {
+ if ($groupElement->getValue() == $chekFlag) {
+ $groupElement->setChecked(TRUE);
+ }
+ }
}
$this->assign('searchRows', $searchRows);
}
CRM_Core_DAO::storeValues($productDAO, $products[$productDAO->id]);
}
- $radio[$productDAO->id] = $form->createElement('radio', NULL, NULL, NULL, $productDAO->id, NULL);
+ $radio[$productDAO->id] = NULL;
$options = $temp = [];
$temp = explode(',', $productDAO->options);
foreach ($temp as $value) {
$form->add('select', 'options_' . $productDAO->id, NULL, $options);
}
- $form->addGroup($radio, 'selectProduct', NULL);
+ $form->addRadio('selectProduct', NULL, $radio);
$form->assign('showRadio', TRUE);
$form->assign('showSelectOptions', TRUE);
// radio button for Honor Type
foreach ($form->_values['soft_credit_types'] as $value) {
- $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
+ $honorTypes[$value] = $softCreditTypes[$value];
}
- $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
+ $form->addRadio('soft_credit_type_id', NULL, $honorTypes, ['allowClear' => TRUE]);
$honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields(
$this->_values['honoree_profile_id'], FALSE,
if ($this->_membershipBlock) {
$this->_currentMemberships = [];
- $membershipTypeIds = $membershipTypes = $radio = [];
+ $membershipTypeIds = $membershipTypes = $radio = $radioOptAttrs = [];
$membershipPriceset = (!empty($this->_priceSetId) && $this->_useForMember);
$allowAutoRenewMembership = $autoRenewOption = FALSE;
}
//add membership type.
- $radio[$memType['id']] = $this->createElement('radio', NULL, NULL, NULL,
- $memType['id'], $javascriptMethod
- );
+ $radio[$memType['id']] = NULL;
+ $radioOptAttrs[$memType['id']] = $javascriptMethod;
if ($cid) {
$membership = new CRM_Member_DAO_Membership();
$membership->contact_id = $cid;
if ($membership->find(TRUE)) {
if (!$membership->end_date) {
unset($radio[$memType['id']]);
+ unset($radioOptAttrs[$memType['id']]);
$this->assign('islifetime', TRUE);
continue;
}
if (!$membershipPriceset) {
if (!$this->_membershipBlock['is_required']) {
$this->assign('showRadioNoThanks', TRUE);
- $radio[''] = $this->createElement('radio', NULL, NULL, NULL, 'no_thanks', NULL);
- $this->addGroup($radio, 'selectMembership', NULL);
+ $radio['no_thanks'] = NULL;
+ $this->addRadio('selectMembership', NULL, $radio, [], NULL, FALSE, $radioOptAttrs);
}
elseif ($this->_membershipBlock['is_required'] && count($radio) == 1) {
$temp = array_keys($radio);
$this->assign('showRadio', FALSE);
}
else {
- $this->addGroup($radio, 'selectMembership', NULL);
+ foreach ($radioOptAttrs as $opt => $attrs) {
+ $attrs['class'] = ' required';
+ }
+ $this->addRadio('selectMembership', NULL, $radio, [], NULL, FALSE, $radioOptAttrs);
}
$this->addRule('selectMembership', ts('Please select one of the memberships.'), 'required');
//CRM-12055
$this->add('text', 'amount_label', ts('Contribution Amounts Label'));
- $default = [$this->createElement('radio', NULL, NULL, NULL, 0)];
+ $default = [0 => NULL];
$this->add('hidden', "price_field_id", '', ['id' => "price_field_id"]);
$this->add('hidden', "price_field_other", '', ['id' => "price_field_option"]);
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
$this->addRule("value[$i]", ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// default
- $default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
+ $default[$i] = NULL;
}
- $this->addGroup($default, 'default');
+ $this->addRadio('default', '', $default);
$this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), NULL, ['onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );"]);
$this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku'));
$this->add('textarea', 'description', ts('Description'), ['cols' => 60, 'rows' => 3]);
-
- $image['image'] = $this->createElement('radio', NULL, NULL, ts('Upload from my computer'), 'image', 'onclick="add_upload_file_block(\'image\');');
- $image['thumbnail'] = $this->createElement('radio', NULL, NULL, ts('Display image and thumbnail from these locations on the web:'), 'thumbnail', 'onclick="add_upload_file_block(\'thumbnail\');');
- $image['default_image'] = $this->createElement('radio', NULL, NULL, ts('Use default image'), 'default_image', 'onclick="add_upload_file_block(\'default\');');
- $image['noImage'] = $this->createElement('radio', NULL, NULL, ts('Do not display an image'), 'noImage', 'onclick="add_upload_file_block(\'noImage\');');
-
- $this->addGroup($image, 'imageOption', ts('Premium Image'));
+ $imageJS = [];
+ $image['image'] = ts('Upload from my computer');
+ $imageJS['image'] = ['onclick' => 'add_upload_file_block(\'image\');', 'class' => 'required'];
+ $image['thumbnail'] = ts('Display image and thumbnail from these locations on the web:');
+ $imageJS['thumbnail'] = ['onclick' => 'add_upload_file_block(\'thumbnail\');', 'class' => 'required'];
+ $image['default_image'] = ts('Use default image');
+ $imageJS['default_image'] = ['onclick' => 'add_upload_file_block(\'default\');', 'class' => 'required'];
+ $image['noImage'] = ts('Do not display an image');
+ $imageJS['noImage'] = ['onclick' => 'add_upload_file_block(\'noImage\');', 'class' => 'required'];
+
+ $this->addRadio('imageOption', ts('Premium Image'), $image, [], NULL, FALSE, $imageJS);
$this->addRule('imageOption', ts('Please select an option for the premium image.'), 'required');
$this->addElement('text', 'imageUrl', ts('Image URL'));
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
- $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
+ $honorTypes[$value] = $softCreditTypes[$value];
}
- $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
+ $form->addRadio('soft_credit_type_id', NULL, $honorTypes, ['allowClear' => TRUE]);
}
}
return $form;
// is active ?
$this->add('checkbox', "option_status[$i]", ts('Active?'));
- $defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
+ $defaultOption[$i] = NULL;
//for checkbox handling of default option
$this->add('checkbox', "default_checkbox_option[$i]", NULL);
}
//default option selection
- $this->addGroup($defaultOption, 'default_option');
+ $this->addRadio('default_option', NULL, $defaultOption);
$_showHide->addToTemplate();
'onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);",
]);
- $default = [$this->createElement('radio', NULL, NULL, NULL, 0)];
+ $default = [0 => NULL];
$this->add('hidden', 'price_field_id', '', ['id' => 'price_field_id']);
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
// label
$this->addRule("value[$i]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// default
- $default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
+ $default[$i] = NULL;
}
- $this->addGroup($default, 'default');
+ $this->addRadio('default', '', $default);
$this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL,
['onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);"]
}
// default
- $default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
+ $default[$i] = NULL;
}
- $this->addGroup($default, 'discounted_default');
+ $this->addRadio('discounted_default', NULL, $default);
}
/**
$form->assign('priceSet', $form->_priceSet);
}
else {
- $eventFeeBlockValues = [];
+ $eventFeeBlockValues = $elements = $elementJS = [];
foreach ($form->_feeBlock as $fee) {
if (is_array($fee)) {
}
$eventFeeBlockValues['amount_id_' . $fee['amount_id']] = $fee['value'];
- $elements[] = &$form->createElement('radio', NULL, '',
- CRM_Utils_Money::format($fee['value']) . ' ' .
- $fee['label'],
- $fee['amount_id'],
- $totalAmountJs
- );
+ $elements[$fee['amount_id']] = CRM_Utils_Money::format($fee['value']) . ' ' . $fee['label'];
+ $elementJS[$fee['amount_id']] = $totalAmountJs;
}
}
$form->assign('eventFeeBlockValues', json_encode($eventFeeBlockValues));
$form->_defaults['amount'] = $form->_values['event']['default_fee_id'] ?? NULL;
- $element = &$form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
+ $element = &$form->addRadio('amount', ts('Event Fee(s)'), $elements, [], '<br />', FALSE, $elementJS);
if (isset($form->_online) && $form->_online) {
$element->freeze();
}
// @todo this is the wrong place for this - it should be done as close to form submission
// as possible
$contributionParams['total_amount'] = $params['amount'];
-
$contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
// lets store it in the form variable so postProcess hook can get to this and use it
$membership = $membershipDefault = $params = [];
foreach ($membershipTypes as $k => $v) {
$membership[] = $this->createElement('advcheckbox', $k, NULL, $v);
- $membershipDefault[] = $this->createElement('radio', NULL, NULL, NULL, $k);
+ $membershipDefault[$k] = NULL;
$membershipRequired[$k] = NULL;
if ($isRecur) {
$autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
$this->assign('auto_renew', $this->_renewOption);
}
$this->addGroup($membership, 'membership_type', ts('Membership Types'));
- $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'))
- ->setAttribute('allowClear', TRUE);
+ $this->addRadio('membership_type_default', ts('Membership Types Default'), $membershipDefault, ['allowClear' => TRUE]);
$this->addFormRule(['CRM_Member_Form_MembershipBlock', 'formRule'], $this->_id);
}
$qf->assign('membershipFieldID', $field->id);
}
- $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
+ $choice[$opt['id']] = $opt['label'];
+ $choiceAttrs[$opt['id']] = $extra;
if ($is_pay_later) {
$qf->add('text', 'txt-' . $elementName, $label, ['size' => '4']);
}
if (in_array($opId, $freezeOptions)) {
self::freezeIfEnabled($choice[$opId], $customOption[$opId]);
// CRM-14696 - Improve display for sold out price set options
- $choice[$opId]->setText('<span class="sold-out-option">' . $choice[$opId]->getText() . ' (' . ts('Sold out') . ')</span>');
+ $choice[$opt['id']] = '<span class="sold-out-option">' . $opt['label'] . ' (' . ts('Sold out') . ')</span>';
}
}
if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') {
- $choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1',
- [
- 'price' => json_encode([$elementName, '0|0']),
- 'data-currency' => $currencyName,
- 'onclick' => 'clearAmountOther();',
- ]
- );
+ $choice['-1'] = ts('No thank you');
+ $choiceAttrs['-1'] = [
+ 'price' => json_encode([$elementName, '0|0']),
+ 'data-currency' => $currencyName,
+ 'onclick' => 'clearAmountOther();',
+ ];
}
if (!$field->is_required) {
$none = ts('- none -');
}
- $choice[] = $qf->createElement('radio', NULL, '', $none, '0',
- ['price' => json_encode([$elementName, '0'])]
- );
+ $choice['0'] = $none;
+ $choiceAttrs['0'] = ['price' => json_encode([$elementName, '0'])];
}
- $element = &$qf->addGroup($choice, $elementName, $label);
+ $element = &$qf->addRadio($elementName, $label, $choice, [], NULL, FALSE, $choiceAttrs);
// make contribution field required for quick config when membership block is enabled
if (($field->name == 'membership_amount' || $field->name == 'contribution_amount')
$this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
$this->add('select', 'option_visibility_id[' . $i . ']', ts('Visibility'), $visibilityType);
- $defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
+ $defaultOption[$i] = NULL;
//for checkbox handling of default option
$this->add('checkbox', "default_checkbox_option[$i]", NULL);
}
//default option selection
- $this->addGroup($defaultOption, 'default_option');
+ $this->addRadio('default_option', NULL, $defaultOption);
$_showHide->addToTemplate();
// is_display_amounts