Preview:
<?php

use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Implements hook_entity_bundle_field_info_alter().
 */
function pos_cfp_bundle_2022_01_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type->id() === 'review' && $bundle === 'acceptance_2022_01') {
    $fields['cf_acceptable_application']->addConstraint('ConditionalValues', [
      'conditions' => [
        [
          'required_choice' => 'no',
          'on_values' => [
            'cf_submit_ontime' => ['no'],
            'cf_submit_original_ontime' => ['no'],
            'cf_scanned_application' => ['no'],
            'cf_application_submitt' => ['no'],
            'cf_liquidation_applicant' => ['no'],
            'cf_rpg_registration' => ['no'],
            'cf_anti_labour_protection' => ['no'],
            'cf_disqualification_conditions' => ['no'],
          ],
          'conjunction' => 'OR',
          'error_message' => 'Ukoliko su polja iz prve dve sekcije "Ne", ovo polje mora biti Ne.',
        ],
        [
          'required_choice' => 'yes',
          'on_values' => [
            'cf_submit_ontime' => ['yes'],
            'cf_submit_original_ontime' => ['yes'],
            'cf_scanned_application' => ['yes'],
            'cf_application_submitt' => ['yes'],
            'cf_liquidation_applicant' => ['yes'],
            'cf_rpg_registration' => ['yes'],
            'cf_anti_labour_protection' => ['yes'],
            'cf_disqualification_conditions' => ['yes'],
          ],
          'conjunction' => 'AND',
          'error_message' => 'Ukoliko su sva polja iz prve dve sekcije "Da", ovo polje mora biti Da.',
        ]
      ],
    ]);
  }
}

/**
 * Implements hook_review_passed_alter().
 */
function pos_cfp_bundle_2022_01_review_passed_alter(&$passed, $entity) {
  if ($entity->bundle() === 'technical_review_2022_01') {
    $passed = $entity->isPrintConfirmed();
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function pos_entity_review_form_review_acceptance_2022_01_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if (isset($form['cf_application_identifier'])) {
    $form['cf_application_identifier']['#states'] = [
      'visible' => [
        ':input[name="cf_only_one_request"]' => ['value' => 'no']
      ],
      'required' => [
        ':input[name="cf_only_one_request"]' => ['value' => 'no']
      ]
    ];
  }
  $form['#validate'][] = 'custom_field_validation';
}

function custom_field_validation($form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $only_request_field = !empty($form_state->getValue('cf_only_one_request')) ? $form_state->getValue('cf_only_one_request')[0]['value'] : '';
  $cf_application_identifier = $form_state->getValue('cf_application_identifier');
  if ($only_request_field === 'no' && empty($cf_application_identifier[0]['value'])) {
    $form_state->setErrorByName('cf_application_identifier', t('Identifikator aplikacije je obavezan ako je podnosioc zahtjeva podnio više od jednog zahtjeva'));
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function pos_cfp_bundle_2022_01_form_review_legal_check_2022_01_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form_object = $form_state->getFormObject();
  $review = $form_object->getEntity();
  foreach ($review->getFields() as $machine_name => $field) {
    if ($field->getFieldDefinition()->getType() === 'options_correction') {
      if ($review->get($machine_name)->value === 'replacement') {
        $form[$machine_name]['#attributes'] = [
          'class' => ['red_field'],
        ];
      }
    }
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter