Skip to main content

Runtime Data

Some attributes are available at runtime (The [additional] configuration data in area bricks, for example). They will be stored in a hidden field but will be picked up very early, so it's possible to get those configuration data in all PRE_SET_DATA Events.

FormBuilder itself requires the runtime data provider if you're using runtime data object resolver in the object output channel. Read more about it here.

Add additional runtime data

services:
App\FormBuilder\RuntimeData\Provider\MyRuntimeData:
autowire: true
tags:
- { name: form_builder.runtime_data_provider}
<?php

namespace App\FormBuilder\RuntimeData\Provider;

use OpenDxp\Bundle\FormBuilderBundle\Form\RuntimeData\RuntimeDataProviderInterface;
use OpenDxp\Bundle\FormBuilderBundle\Model\FormDefinitionInterface;

class MyRuntimeData implements RuntimeDataProviderInterface
{
public function getRuntimeDataId(): string
{
return 'my_runtime_options_identifier';
}

public function hasRuntimeData(FormDefinitionInterface $formDefinition): bool
{
// add your logic here.
$hasData = false;

return $hasData;
}

public function getRuntimeData(FormDefinitionInterface $formDefinition): mixed
{
return 'my_runtime_option_value';
}
}

Availability

From now on, your my_runtime_options_identifier option is available in all the form builder formRuntimeData configuration node, for example in the ChannelSubjectGuardEvent event.