My goal is to make the "revision log message" required if "Create new revision" is checked on create/edit node.
I do able to add the visible and required mark based on the "create new revision" field.
function hook_form_node_form_alter(&$form, &$form_state, $form_id) {
$form['revision_information']['log']['#states'] = [
'required' => [
':input[name="revision"]' => ['checked' => TRUE],
],
'visible' => [
':input[name="revision"]' => ['checked' => TRUE],
],
];
}
I also able to make the "revision log message" as required.
function hook_form_node_form_alter(&$form, &$form_state, $form_id) {
$form['revision_information']['log']['#required'] = [
'required' => [
':input[name="revision"]' => ['checked' => TRUE],
],
];
}
But I don't know how to make the field required based on the "create new revision" checkbox.
PS: I want to make this simple and don't want to use the "Enforce revision log message" module.
// update 1: I found it require a custom hook validate and Im searching for it