Skip to content

Prefilling fields

A field can start with a value taken from the logged-in website user or from a data object the page passes to the form, for example a customer’s name and email, or the product a request is about.

Form editor > Build tab > select a field > Fill in from:

Choice Value comes from
Nothing the field starts empty (default)
Logged-in user the Symfony security user of the website (your frontend login), e.g. a Customer data object
Data object of the page the object the template passes to pimkit_form()

Property is the getter to call: email calls getEmail(), address.city calls getAddress() and then getCity() (or the city key of an array). Up to five levels. Works for all fields with a value except file uploads.

{# A product page: the "product" field is filled from the product object #}
{{ pimkit_form('product_inquiry', { object: product }) }}
{# Or set values directly, by field name. These win over the field's own source #}
{{ pimkit_form('contact', { prefill: { topic: 'support', campaign: app.request.query.get('c') } }) }}

The areabrick has no object to pass, so “Data object of the page” works where you render the form with pimkit_form() in your own template.

  • Visible fields: the value is only a starting point. The visitor can change it, and after a failed submit the visitor’s own input is shown again.
  • Hidden fields are sealed: their prefilled values are signed into the form (_pk_prefill), and on submit the signed value replaces whatever the browser sent. A visitor cannot change them. A hidden field with a prefill source that arrives without a valid seal (e.g. from a headless client) is stored empty.
  • Dates are written as YYYY-MM-DD for date fields, true becomes a ticked checkbox, lists fill checkbox groups. Objects without a text form are skipped. Nothing found means the field starts empty.
  • Studio users (Pimcore backend accounts) never prefill: the preview shows the form empty.

A form prefilled from the logged-in user is personal. Make sure pages with such a form are not served from a shared full-page or CDN cache to other visitors (check your Pimcore full page cache exclusions and CDN rules for logged-in users). Object and template values are the same for every visitor of the page, so those pages stay cacheable.