/**
* Common buildForm tasks required by all searches.
*/
- public function buildQuickform() {
+ public function buildQuickForm() {
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header')
->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
}
/**
- * @param CRM_Core_Form $form
+ * Get the metadata for fields to be included on the grant search form.
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public static function getSearchFieldMetadata() {
+ $fields = [
+ 'participant_status_id',
+ ];
+ $metadata = civicrm_api3('Participant', 'getfields', [])['values'];
+ return array_intersect_key($metadata, array_flip($fields));
+ }
+
+ /**
+ * Build the event search form.
+ *
+ * @param \CRM_Event_Form_Search $form
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public static function buildSearchForm(&$form) {
+ $form->addSearchFieldMetadata(['Participant' => self::getSearchFieldMetadata()]);
+ $form->addFormFieldsFromMetadata();
$dataURLEventFee = CRM_Utils_System::url('civicrm/ajax/eventFee',
"reset=1",
FALSE, NULL, FALSE
$form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', [1 => '<em>%1</em>']));
- $form->addSelect('participant_status_id',
- [
- 'entity' => 'participant',
- 'label' => ts('Participant Status'),
- 'multiple' => 'multiple',
- 'option_url' => NULL,
- 'placeholder' => ts('- any -'),
- ]
- );
-
$form->addSelect('participant_role_id',
[
'entity' => 'participant',
* @copyright CiviCRM LLC (c) 2004-2019
*/
-/**
- * Files required
- */
-
/**
* This file is for civievent search
*/
*/
protected $_ssID;
+ /**
+ * Metadata of all fields to include on the form.
+ *
+ * @var array
+ */
+ protected $searchFieldMetadata = [];
+
+
+ /**
+ * @return string
+ */
+ public function getDefaultEntity() {
+ return 'Participant';
+ }
+
/**
* Processing needed for buildForm and later.
*
/**
* Build the form object.
*
- *
* @return void
+ *
+ * @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
parent::buildQuickForm();