protected function getEmailRecipientRequiredFields()
    {
        $requiredFields = [];
        $recipientFieldsMap = [
            'EmailAddress' => 'SendEmailToField',
            'EmailSubject' => 'SendEmailSubjectField',
            'EmailReplyTo' => 'SendEmailFromField'
        ];

        foreach ($this->getController()->data()->EmailRecipients() as $recipient) {
            foreach ($recipientFieldsMap as $textField => $dynamicFormField) {
                if (empty($recipient->$textField) && $recipient->getComponent($dynamicFormField)->exists()) {
                    $requiredFields[] = $recipient->getComponent($dynamicFormField)->Name;
                }
            }
        }

        return $requiredFields;
    }
protected function getEmailRecipientRequiredFields()
    {
        $requiredFields = [];
        $recipientFieldsMap = [
            'EmailAddress' => 'SendEmailToField',
            'EmailSubject' => 'SendEmailSubjectField',
            'EmailReplyTo' => 'SendEmailFromField'
        ];

        foreach ($this->getController()->data()->EmailRecipients() as $recipient) {
            foreach ($recipientFieldsMap as $textField => $dynamicFormField) {
                if (empty($recipient->$textField) && $recipient->getComponent($dynamicFormField)->exists()) {
                    $requiredFields[] = $recipient->getComponent($dynamicFormField)->Name;
                }
            }
        }

        return $requiredFields;
    }
protected function getEmailRecipientRequiredFields ( ) { $ requiredFields = [ ] ; $ recipientFieldsMap = [ 'EmailAddress' => 'SendEmailToField' , 'EmailSubject' => 'SendEmailSubjectField' , 'EmailReplyTo' => 'SendEmailFromField' ] ; foreach ( $ this -> getController ( ) -> data ( ) -> EmailRecipients ( ) as $ recipient ) { foreach ( $ recipientFieldsMap as $ textField => $ dynamicFormField ) { if ( empty ( $ recipient -> $ textField ) && $ recipient -> getComponent ( $ dynamicFormField ) -> exists ( ) ) { $ requiredFields [ ] = $ recipient -> getComponent ( $ dynamicFormField ) -> Name ; } } } return $ requiredFields ; }
Push fields into the RequiredFields array if they are used by any Email recipients.
Ignore if there is a backup i.e. the plain string field is set

@return array required fields names
Push fields into the RequiredFields array if they are used by any Email recipients . Ignore if there is a backup i . e . the plain string field is set