mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10566 from kinglozzer/form-extension-hook
NEW: Add onBeforeRender extension hook to Form
This commit is contained in:
commit
00f0b01d0e
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user