$form_object = $form_state->getFormObject(); $form_title = $form_object->title;
$form_object = $form_state->getFormObject(); $form_custom_output = $form_object->customMethod();Brief Explanation: In the first example, we retrieve the title property of the form object using the getFormObject method and store it in a variable called $form_title. In the second example, we retrieve the entire form object using the getFormObject method and then call a custom method called customMethod() that is defined in our form object class. Package Library: Drupal's core.form package library.