interface FormRendererInterface
Renders a form into HTML.
FormRendererEngineInterface | getEngine() Returns the engine used by this renderer. | |
setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true) Sets the theme(s) to be used for rendering a view and its children. | ||
string | renderBlock(FormView $view, string $blockName, array $variables = array()) Renders a named block of the form theme. | |
string | searchAndRenderBlock(FormView $view, string $blockNameSuffix, array $variables = array()) Searches and renders a block for a given name suffix. | |
string | renderCsrfToken(string $tokenId) Renders a CSRF token. | |
string | humanize(string $text) Makes a technical name human readable. |
Returns the engine used by this renderer.
FormRendererEngineInterface | The renderer engine |
Sets the theme(s) to be used for rendering a view and its children.
FormView | $view | The view to assign the theme(s) to |
mixed | $themes | The theme(s). The type of these themes is open to the implementation. |
bool | $useDefaultThemes | If true, will use default themes specified in the renderer |
Renders a named block of the form theme.
FormView | $view | The view for which to render the block |
string | $blockName | The name of the block |
array | $variables | The variables to pass to the template |
string | The HTML markup |
Searches and renders a block for a given name suffix.
The block is searched by combining the block names stored in the form view with the given suffix. If a block name is found, that block is rendered.
If this method is called recursively, the block search is continued where a block was found before.
FormView | $view | The view for which to render the block |
string | $blockNameSuffix | The suffix of the block name |
array | $variables | The variables to pass to the template |
string | The HTML markup |
Renders a CSRF token.
Use this helper for CSRF protection without the overhead of creating a form.
<input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
Check the token in your action using the same token ID.
// $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface
if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
throw new \RuntimeException('CSRF attack detected.');
}
string | $tokenId | The ID of the CSRF token |
string | A CSRF token |
Makes a technical name human readable.
Sequences of underscores are replaced by single spaces. The first letter of the resulting string is capitalized, while all other letters are turned to lowercase.
string | $text | The text to humanize |
string | The humanized text |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Form/FormRendererInterface.html