function hook_scheduler_hide_publish_date in Scheduler 2.x
Hook function to hide the Publish On field.
This hook is called from scheduler_form_alter() when adding or editing an entity. It gives modules the ability to hide the scheduler publish_on input field so that a date may not be entered or changed. Note that it does not give the ability to force the field to be displayed, as that could override a more significant setting. It can only be used to hide the field.
This hook was introduced for scheduler_content_moderation_integration. See https://www.drupal.org/project/scheduler/issues/2798689
Parameters
array $form: An associative array containing the structure of the form, as used in hook_form_alter().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form, as used in hook_form_alter().
\Drupal\Core\Entity\EntityInterface $entity: The entity object being added or edited.
Return value
bool TRUE to hide the publish_on field. FALSE or NULL to leave the setting unchanged.
1 function implements hook_scheduler_hide_publish_date()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- scheduler_api_test_scheduler_hide_publish_date in tests/
modules/ scheduler_api_test/ scheduler_api_test.module - Implements hook_scheduler_hide_publish_date().
File
- ./
scheduler.api.php, line 195 - API documentation for the Scheduler module.
Code
function hook_scheduler_hide_publish_date(array $form, FormStateInterface $form_state, EntityInterface $entity) {
if ($some_condition) {
return TRUE;
}
}