$js = array('onChange' => 'checkLocation( this.id );');
}
- $form->addSelect("address[$blockId][location_type_id]", array('data-api-entity' => 'address', 'class' => 'six') + $js);
+ $form->addSelect("address[$blockId][location_type_id]", array('data-api-entity' => 'address', 'class' => 'eight') + $js);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
$form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email');
if (isset($form->_contactType) || $blockEdit) {
//Block type
- $form->addSelect("email[$blockId][location_type_id]", array('data-api-entity' => 'email', 'class' => 'six'));
+ $form->addSelect("email[$blockId][location_type_id]", array('data-api-entity' => 'email', 'class' => 'eight'));
$multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
$form->applyFilter('__ALL__', 'trim');
//IM provider select
- $form->addSelect("im[$blockId][provider_id]", array('data-api-entity' => 'im', 'class' => 'six'));
+ $form->addSelect("im[$blockId][provider_id]", array('data-api-entity' => 'im', 'class' => 'eight'));
//Block type select
- $form->addSelect("im[$blockId][location_type_id]", array('data-api-entity' => 'im', 'class' => 'six'));
+ $form->addSelect("im[$blockId][location_type_id]", array('data-api-entity' => 'im', 'class' => 'eight'));
//IM box
$form->addElement('text', "im[$blockId][name]", ts('Instant Messenger'),
$form->applyFilter('__ALL__', 'trim');
//phone type select
- $form->addSelect("phone[$blockId][phone_type_id]", array('data-api-entity' => 'phone', 'class' => 'six'));
+ $form->addSelect("phone[$blockId][phone_type_id]", array('data-api-entity' => 'phone', 'class' => 'eight'));
//main phone number with crm_phone class
$form->add('text', "phone[$blockId][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve')));
if (isset($form->_contactType) || $blockEdit) {
//Block type select
- $form->addSelect("phone[$blockId][location_type_id]", array('data-api-entity' => 'phone', 'class' => 'six'));
+ $form->addSelect("phone[$blockId][location_type_id]", array('data-api-entity' => 'phone', 'class' => 'eight'));
//is_Primary radio
$js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
$form->applyFilter('__ALL__', 'trim');
//Website type select
- $form->addSelect("website[$blockId][website_type_id]", array('data-api-entity' => 'website', 'class' => 'six'));
+ $form->addSelect("website[$blockId][website_type_id]", array('data-api-entity' => 'website', 'class' => 'eight'));
//Website box
$form->addElement('text', "website[$blockId][url]", ts('Website'),
return $info;
}
+
+ /**
+ * Get options for a given field.
+ * @see CRM_Core_DAO::buildOptions
+ *
+ * @param String $fieldName
+ * @param String $context: @see CRM_Core_DAO::buildOptionsContext
+ * @param Array $props: whatever is known about this dao object
+ *
+ * @return array|bool
+ */
+ public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+ $params = array();
+ // Special logic for fields whose options depend on context or properties
+ switch ($fieldName) {
+ case 'financial_type_id':
+ // Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get
+ return CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
+ break;
+ }
+ return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+ }
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage');
// financial Type
- $financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
- $this->add('select', 'financial_type_id',
- ts('Financial Type'),
- $financialType,
- TRUE
- );
+ $this->addSelect('financial_type_id', array(), TRUE);
// name
$this->add('text', 'title', ts('Title'), $attributes['title'], TRUE);
$freezeCurrency = FALSE
) {
$currencies = CRM_Core_OptionGroup::values('currencies_enabled');
+ $options = array('class' => 'crm-select2 eight');
if (!$required) {
- $currencies = array(
- '' => ts('- select -')) + $currencies;
+ $currencies = array('' => '') + $currencies;
+ $options['placeholder'] = ts('- none -');
}
- $ele = $this->add('select', $name, $label, $currencies, $required);
+ $ele = $this->add('select', $name, $label, $currencies, $required, $options);
if ($freezeCurrency) {
$ele->freeze();
}
return NULL;
}
// We don't have good mapping so have to do a bit of guesswork from the menu
- list(, , , $ent) = explode('_', $daoName);
+ list(, $parent, , $child) = explode('_', $daoName);
$sql = "SELECT path FROM civicrm_menu
- WHERE page_callback LIKE '%CRM_Admin_Page_$ent%'
+ WHERE page_callback LIKE '%CRM_Admin_Page_$child%' OR page_callback LIKE '%CRM_{$parent}_Page_$child%'
+ ORDER BY page_callback
LIMIT 1";
return CRM_Core_Dao::singleValueQuery($sql);
}
}
CRM_Core_DAO::executeQuery($query, $params);
}
+
+ /**
+ * Get options for a given field.
+ * @see CRM_Core_DAO::buildOptions
+ *
+ * @param String $fieldName
+ * @param String $context: @see CRM_Core_DAO::buildOptionsContext
+ * @param Array $props: whatever is known about this dao object
+ *
+ * @return array|bool
+ */
+ public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+ $params = array();
+ // Special logic for fields whose options depend on context or properties
+ switch ($fieldName) {
+ case 'financial_type_id':
+ // Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get
+ return CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
+ break;
+ }
+ return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+ }
}
// add event title, make required if this is not a template
$this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate);
- $event = CRM_Core_OptionGroup::values('event_type');
-
- $this->add('select',
- 'event_type_id',
- ts('Event Type'),
- array(
- '' => ts('- select -')) + $event,
- TRUE,
- array('onChange' => "CRM.buildCustomData( 'Event', this.value );")
+ $this->addSelect('event_type_id',
+ array('onChange' => "CRM.buildCustomData( 'Event', this.value );"),
+ TRUE
);
//CRM-7362 --add campaigns.
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
- $participantRole = CRM_Core_OptionGroup::values('participant_role');
- $this->add('select',
- 'default_role_id',
- ts('Participant Role'),
- $participantRole,
- TRUE
- );
+ $this->addSelect('default_role_id', array(), TRUE);
- $participantListing = CRM_Core_OptionGroup::values('participant_listing');
- $this->add('select',
- 'participant_listing_id',
- ts('Participant Listing'),
- array(
- '' => ts('Disabled')) + $participantListing,
- FALSE
- );
+ $this->addSelect('participant_listing_id', array('placeholder' => ts('Disabled')));
$this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']);
$this->addWysiwyg('description', ts('Complete Description'), $attributes['event_description']);
);
// financial type
- $financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
- $this->add('select', 'financial_type_id', ts('Financial Type'),
- array('' => ts('- select -')) + $financialType
- );
+ $this->addSelect('financial_type_id');
// add pay later options
$this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL,
array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);")
$this->assign('recipientMapping', json_encode($recipientMapping));
- $entity = $this->add('select', 'entity', ts('Recipient(s)'), $sel3[$this->_mappingID][0], TRUE);
- $entity->setMultiple(TRUE);
+ // Fixme: hack to adjust the output of CRM_Core_BAO_ActionSchedule::getSelection so it looks nice with the jQuery.select2 plugin
+ // TODO: fix this upstream
+ $options = $sel3[$this->_mappingID][0];
+ $attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]);
+ unset($options[0]);
+ $entity = $this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes);
//get the frequency units.
$this->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units');
$this->add('select', 'limit_to', ts('Limit Options'), $limitOptions);
$this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient],
- FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
+ FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
);
$recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'),
- $sel3[$this->_mappingID][0]
+ $sel3[$this->_mappingID][0], FALSE, array('class' => 'crm-select2 huge')
);
$recipientListing->setMultiple(TRUE);
$this->assign('tokenUrl', $tokenUrl);
$this->add('text', 'recipient_manual_id', ts('Manual Recipients'));
- $this->addElement('select', 'group_id', ts('Group'),
- CRM_Core_PseudoConstant::staticGroup()
+ $this->add('select', 'group_id', ts('Group'),
+ CRM_Core_PseudoConstant::staticGroup(), FALSE, array('class' => 'crm-select2 huge')
);
CRM_Mailing_BAO_Mailing::commonCompose($this);
// If that didn't work, try a different pattern
if (!$shortName) {
- list(, $entity) = explode('_', $className);
- $daoName = "CRM_{$entity}_DAO_$entity";
+ list(, $parent, , $child) = explode('_', $className);
+ $daoName = "CRM_{$parent}_DAO_$child";
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try a different pattern
if (!$shortName) {
- list(, , , $entity) = explode('_', $className);
- $daoName = "CRM_Core_DAO_$entity";
+ $daoName = "CRM_{$parent}_DAO_$parent";
+ $shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
+ }
+
+ // If that didn't work, try a different pattern
+ if (!$shortName) {
+ $daoName = "CRM_Core_DAO_$child";
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
if (!$shortName) {
<table class="form-layout-compressed">
{if $form.template_id}
<tr class="crm-event-manage-eventinfo-form-block-template_id">
- <td class="label">{$form.template_id.label}</td>
- <td>{$form.template_id.html} {help id="id-select-template" isTemplate=$isTemplate}</td>
+ <td class="label">{$form.template_id.label} {help id="id-select-template" isTemplate=$isTemplate}</td>
+ <td>{$form.template_id.html}</td>
</tr>
{/if}
{if $form.template_title}
<tr class="crm-event-manage-eventinfo-form-block-template_title">
- <td class="label">{$form.template_title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='template_title' id=$eventID}{/if}</td>
- <td>{$form.template_title.html} {help id="id-template-title"}</td>
+ <td class="label">{$form.template_title.label} {help id="id-template-title"}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='template_title' id=$eventID}{/if}</td>
+ <td>{$form.template_title.html}</td>
</tr>
{/if}
<tr class="crm-event-manage-eventinfo-form-block-event_type_id">
campaignTrClass="crm-event-manage-eventinfo-form-block-campaign_id"}
<tr class="crm-event-manage-eventinfo-form-block-default_role_id">
- <td class="label">{$form.default_role_id.label}</td>
- <td>{$form.default_role_id.html} {help id="id-participant-role"}
+ <td class="label">{$form.default_role_id.label} {help id="id-participant-role"}</td>
+ <td>{$form.default_role_id.html}
</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-participant_listing_id">
- <td class="label">{$form.participant_listing_id.label}</td>
- <td>{$form.participant_listing_id.html} {help id="id-listing" isTemplate=$isTemplate action=$action entityId=$entityId}</td>
+ <td class="label">{$form.participant_listing_id.label} {help id="id-listing" isTemplate=$isTemplate action=$action entityId=$entityId}</td>
+ <td>{$form.participant_listing_id.html}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-title">
<td class="label">{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='title' id=$eventID}{/if}</td>
</tr>
{/if}
<tr class="crm-event-manage-eventinfo-form-block-max_participants">
- <td class="label">{$form.max_participants.label}</td>
- <td>{$form.max_participants.html|crmAddClass:four} {help id="id-max_participants" waitlist=$waitlist}</td>
+ <td class="label">{$form.max_participants.label} {help id="id-max_participants" waitlist=$waitlist}</td>
+ <td>{$form.max_participants.html|crmAddClass:four}</td>
</tr>
<tr id="id-waitlist" class="crm-event-manage-eventinfo-form-block-has_waitlist">
{if $waitlist}
{* added onload javascript for source contact*}
{literal}
<script type="text/javascript">
+ cj().crmAccordions();
var recipient_manual = '';
var recipient_manual_id = null;
var toDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1&noemail=1' h=0 }{literal}"; {/literal}