Skip to content

Commit

Permalink
UHF-9496: Add form states
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Apr 4, 2024
1 parent bbd23f6 commit 1318339
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ function hdbt_admin_tools_form_node_form_alter(&$form, &$form_state, $form_id):
$form['actions']['submit']['#submit'][] = 'hdbt_admin_tools_node_form_submit_callback';
}

/**
* Implements hook_form_FORM_ID_alter().
*/
function hdbt_admin_tools_form_tpr_unit_form_alter(&$form, &$form_state, $form_id): void {
$form['field_phone_label']['#states'] = [
'visible' => [
':input[name="field_phone_with_contacts[value]"]' => ['checked' => TRUE],
],
];

// Required state must the widget rather than the form element.
$form['field_phone_label']['widget'][0]['value']['#states'] = [
'required' => [
':input[name="field_phone_with_contacts[value]"]' => ['checked' => TRUE],
],
];
}

/**
* Form submit callback for node forms.
*
Expand Down

0 comments on commit 1318339

Please sign in to comment.