4 added 1539 characters in body
source | link

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) When I add a condition and try to print variables inside it on New Participant Registration it does not show up.(probably since its entering )

 $apiRequest['entity'] == 'event'

/**
 * Implements hook_civicrm_apiWrappers
 */
function custom_changes_civicrm_apiWrappers(&$wrappers, $apiRequest) {

  if ($apiRequest['entity'] == 'event' ) {
    print_r('<pre>');
    print_r($apiRequest);
    print_r($wrappers);
    die('ed'); 
 }
}

enter image description here

On adding the code answered below

if ('CRM_Event_Form_Participant' == $formName) {
    $elementIndex = $form->_elementIndex['event_id'];
    $element = & $form->_elements[$elementIndex];
    $dataApiParams = json_decode($element->_attributes['data-api-params'], TRUE);
    $dataApiParams['params'] = ['parent_event_id' => ['IS NULL' => 1]];
    $element->_attributes['data-api-params'] = json_encode($dataApiParams);   }

I get an error (when I comment I don't get the error).

Error: Call to undefined method stdClass::getName() in HTML_QuickForm->accept() (line 1686 of csites\all\modules\civicrm\packages\HTML\QuickForm.php).

To fix that I actually went to QuickForm.php and added an if condition as seen below

if(method_exists($element,'getName')

Is that a correct method and if not , how can I debug that further based on the error log.

 function accept(&$renderer)
    {
        $renderer->startForm($this);
        foreach (array_keys($this->_elements) as $key) {
            $element =& $this->_elements[$key];
            if (method_exists($element,'getName')){
            $elementName = $element->getName();
            $required    = ($this->isElementRequired($elementName) && !$element->isFrozen());
            $error       = $this->getElementError($elementName);
            $element->accept($renderer, $required, $error);
            }
        }
        $renderer->finishForm($this);
    } // end func accept

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) When I add a condition and try to print variables inside it on New Participant Registration it does not show up.(probably since its entering )

 $apiRequest['entity'] == 'event'

/**
 * Implements hook_civicrm_apiWrappers
 */
function custom_changes_civicrm_apiWrappers(&$wrappers, $apiRequest) {

  if ($apiRequest['entity'] == 'event' ) {
    print_r('<pre>');
    print_r($apiRequest);
    print_r($wrappers);
    die('ed'); 
 }
}

enter image description here

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) When I add a condition and try to print variables inside it on New Participant Registration it does not show up.(probably since its entering )

 $apiRequest['entity'] == 'event'

/**
 * Implements hook_civicrm_apiWrappers
 */
function custom_changes_civicrm_apiWrappers(&$wrappers, $apiRequest) {

  if ($apiRequest['entity'] == 'event' ) {
    print_r('<pre>');
    print_r($apiRequest);
    print_r($wrappers);
    die('ed'); 
 }
}

enter image description here

On adding the code answered below

if ('CRM_Event_Form_Participant' == $formName) {
    $elementIndex = $form->_elementIndex['event_id'];
    $element = & $form->_elements[$elementIndex];
    $dataApiParams = json_decode($element->_attributes['data-api-params'], TRUE);
    $dataApiParams['params'] = ['parent_event_id' => ['IS NULL' => 1]];
    $element->_attributes['data-api-params'] = json_encode($dataApiParams);   }

I get an error (when I comment I don't get the error).

Error: Call to undefined method stdClass::getName() in HTML_QuickForm->accept() (line 1686 of csites\all\modules\civicrm\packages\HTML\QuickForm.php).

To fix that I actually went to QuickForm.php and added an if condition as seen below

if(method_exists($element,'getName')

Is that a correct method and if not , how can I debug that further based on the error log.

 function accept(&$renderer)
    {
        $renderer->startForm($this);
        foreach (array_keys($this->_elements) as $key) {
            $element =& $this->_elements[$key];
            if (method_exists($element,'getName')){
            $elementName = $element->getName();
            $required    = ($this->isElementRequired($elementName) && !$element->isFrozen());
            $error       = $this->getElementError($elementName);
            $element->accept($renderer, $required, $error);
            }
        }
        $renderer->finishForm($this);
    } // end func accept
3 added 155 characters in body
source | link

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) When I add a condition and try to print variables inside it on New Participant Registration it does not show up.(probably since its entering )

 $apiRequest['entity'] == 'event'

/**
 * Implements hook_civicrm_apiWrappers
 */
function custom_changes_civicrm_apiWrappers(&$wrappers, $apiRequest) {

  if ($apiRequest['entity'] == 'event' ) {
    print_r('<pre>');
    print_r($apiRequest);
    print_r($wrappers);
    die('ed'); 
 }
}

enter image description here

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) enter image description here

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) When I add a condition and try to print variables inside it on New Participant Registration it does not show up.(probably since its entering )

 $apiRequest['entity'] == 'event'

/**
 * Implements hook_civicrm_apiWrappers
 */
function custom_changes_civicrm_apiWrappers(&$wrappers, $apiRequest) {

  if ($apiRequest['entity'] == 'event' ) {
    print_r('<pre>');
    print_r($apiRequest);
    print_r($wrappers);
    die('ed'); 
 }
}

enter image description here

2 added 155 characters in body
source | link

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) enter image description here

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

On Register Particpant Page, I see list of all Events under Event dropdown
As per the requirement, I am using Recurring Entity to have repeat
events,so I need to hide repeat events and display only parent events
How can we alter the results in the Event dropdown enter image description here

The Event dropdown has this form structure (from hook_buildForm) enter image description here

1
source | link