Merge pull request #10566 from kinglozzer/form-extension-hook

NEW: Add onBeforeRender extension hook to Form
This commit is contained in:
Daniel Hensby 2022-11-02 23:54:22 +00:00 committed by GitHub
commit 00f0b01d0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -1552,10 +1552,13 @@ class Form extends ViewableData implements HasRequestHandler
HTTPCacheControlMiddleware::singleton()->disableCache();
}
$return = $this->renderWith($this->getTemplates());
$context = $this;
$this->extend('onBeforeRender', $context);
$return = $context->renderWith($context->getTemplates());
// Now that we're rendered, clear message
$this->clearMessage();
$context->clearMessage();
return $return;
}

View File

@ -927,7 +927,7 @@ class FormField extends RequestHandler
$context = $context->customise($properties);
}
$result = $context->renderWith($this->getTemplates());
$result = $context->renderWith($context->getTemplates());
// Trim whitespace from the result, so that trailing newlines are suppressed. Works for strings and HTMLText values
if (is_string($result)) {
@ -959,10 +959,10 @@ class FormField extends RequestHandler
$this->extend('onBeforeRenderHolder', $context, $properties);
if (count($properties ?? [])) {
$context = $this->customise($properties);
$context = $context->customise($properties);
}
return $context->renderWith($this->getFieldHolderTemplates());
return $context->renderWith($context->getFieldHolderTemplates());
}
/**