本文整理汇总了PHP中Drupal\Core\Form\FormState::getFormObject方法的典型用法代码示例。如果您正苦于以下问题:PHP FormState::getFormObject方法的具体用法?PHP FormState::getFormObject怎么用?PHP FormState::getFormObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormState
的用法示例。
在下文中一共展示了FormState::getFormObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* Form submit handler to flush Mollom session and form information from cache.
*
* This is necessary as the entity forms will no longer automatically save
* the data with the entity.
*
* @todo: Possible problems:
* - This submit handler is invoked too late; the primary submit handler might
* send out e-mails directly after saving the entity (e.g.,
* user_register_form_submit()), so mollom_mail_alter() is invoked before
* Mollom session data has been saved.
*/
public static function submitForm($form, FormState $form_state)
{
// Some modules are implementing multi-step forms without separate form
// submit handlers. In case we reach here and the form will be rebuilt, we
// need to defer our submit handling until final submission.
$is_rebuilding = $form_state->isRebuilding();
if ($is_rebuilding) {
return;
}
$mollom = $form_state->getValue('mollom');
$form_object = $form_state->getFormObject();
// If an 'entity' and a 'post_id' mapping was provided via
// hook_mollom_form_info(), try to automatically store Mollom session data.
if (empty($mollom) || empty($mollom['entity']) || !$form_state->getFormObject() instanceof EntityFormInterface) {
return;
}
/* @var $form_object \Drupal\Core\Entity\EntityFormInterface */
$entity_id = $form_object->getEntity()->id();
$data = (object) $mollom;
$data->id = $entity_id;
$data->moderate = $mollom['require_moderation'] ? 1 : 0;
$stored_data = ResponseDataStorage::save($data);
$form_state->setValue(['mollom', 'data'], $stored_data);
}
示例2: testPrepareCallbackArray
/**
* @covers ::prepareCallback
*/
public function testPrepareCallbackArray()
{
$form_state = new FormState();
$form_state->setFormObject(new PrepareCallbackTestForm());
$callback = [$form_state->getFormObject(), 'buildForm'];
$processed_callback = $form_state->prepareCallback($callback);
$this->assertEquals($callback, $processed_callback);
}