Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Documentation/Global/Render/Text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,30 @@ TCA configuration.
.. literalinclude:: _codesnippets/_tt_content_textarea.php
:caption: my_theme/Configuration/TCA/Overrides/tt_content.php

.. _typo3-fluid-render-text-usage-optional-argument:

Using the `optional` argument
=============================

Accessing a field that is not available in a record usually raises an
exception. However, in shared templates that need to be rendered even if a field
happens to be missing in a particular record, setting the boolean argument
:html:`optional` to :html:`true` means the ViewHelper will return
:html:`null` instead of an exception.

.. code-block:: html
:caption: SharedHeader.fluid.html

<f:variable name="header">{record -> f:render.text(field: 'header', optional: true)}</f:variable>

This is useful for shared partials such as in :html:`fluid_styled_content`
where header partials can be reused by content elements when the transformed record
does not provide a :html:`header` or :html:`subheader` field. Without
:html:`optional="true"`, rendering the partial would raise a
:php:`RecordPropertyNotFoundException`. If :html:`optional="true"`, the ViewHelper
returns :html:`null` and the partial can continue to handle the missing value
gracefully.

.. _typo3-fluid-render-text-extbase:

Rendering texts from Extbase models
Expand Down
Loading