Skip to content

Latest commit

 

History

History
125 lines (92 loc) · 6.29 KB

11_ObjectChannel.md

File metadata and controls

125 lines (92 loc) · 6.29 KB

Object Channel

image

Use the object channel to generate or enrich DataObjects.

Configuration

There are two different resolver strategies you can rely on.

I. Create new Object

If you want to create a new object after each form submission, use this one. You need to choose a data class afterwards.

You're able to map fields and field collections.

Options

Name Description
Object Storage Path Define where all the objects should be stored.
Object Class Choose, which data object type should be created.

II. Use existing Object

If you want to append data to a existing object after each form submission, use this one. You need to define an object reference afterwards.

Attention: You're able to map field collections only!

Options

Name Description
Referencing Object Define where all the objects should be stored.
Dynamic Object Resolver If any resolver has been registered, you could choose one. Read more about the dynamic object resolver below.

Available Mapping Data

image

This table shows all possible data mapping fields:

FormBuilder Type Allowed Pimcore Type
Text Text/Input, Text/Textarea, Text/Wysiwyg, CRM/Firstname, CRM/Lastname, CRM/Email
Hidden Text/Input, Text/Textarea, Text/Wysiwyg
Text Area Text/Textarea, Text/Wysiwyg
Integer Text/Input, Text/Textarea, Text/Wysiwyg, Number/Number, Number/Slider
Checkbox Other/Checkbox, CRM/NewsletterActive, CRM/NewsletterConfirmed, CRM/Consent
Date Date/Date
Date Time Date/DateTime
Time Date/Time
Birthday Date/Date
Choice Text/Input,Select/Select, Select/MultiSelect, CRM/Gender
Dynamic Choice Text/Input,Select/Select, Select/MultiSelect, CRM/Gender
Country Text/Input,Select/Country, Select/Country (MultiSelect)
Html Tag unsupported
Snippet unsupported
reCAPTCHA v3 unsupported
Dynamic Multi File unsupported
Submit unsupported

Dynamic Choices Mapping

If you're using the dynamic choice type mapping, make sure your mapped pimcore field is connected to the same options provider source!

Container Mapping

image

This Channel also allows you to store 1:N container data (Repeater, Fieldset) by storing them as a field collection in your data object. You need to add the field collection relation to your form field. After that you're able to sub-map the field collection object.

Dynamic Object Validation Constraints

image

There are two default validation constrains available within the field collection mapping.

Type Description
Uniqueness Validation If enabled, you need to define a referencing uniqueness field. This will raise an GuardOutputWorkflowException exception, if the validation fails. The message will be translated via pimcore translation engine.
Count Validation If enabled, you ned to define a referencing count field (mostly a number field). This will raise an GuardOutputWorkflowException exception, if the validation fails. The message will be translated via pimcore translation engine.

Events

You're able to implement a guard and enrichment event. Read more about it here.

Dynamic Object Resolver

Note: The Dynamic Object Resolver is only available if you're using the "Use existing Object" strategy!

Example: You want to show some events on your website. Every event has its own detail page on your website. To allow user to apply to your event, you may want to add a form at the bottom of those event pages.

After you've created an object output workflow you'll shortly run into a simple question: Does FormBuilder know, which existing event should be used to append the form data? The answer is simple: No.

To achieve this, you need to do some configuration work. Luckily, FormBuilder ships some pre-configured services, so you only need to configure them properly.

I. Add Runtime Data

First, you need to determinate an object identifier. Mostly it's an ID in your query string.

form_builder.form.runtime_data.event_id_fetcher:
    class: FormBuilderBundle\Form\RuntimeData\Provider\RequestDataProvider
    autowire: true
    arguments:
        $expr: 'request.query.get("eventId", null)'
        $runtimeId: 'event_id'
    tags:
        - { name: form_builder.runtime_data_provider}

II. Add dynamic Object Resolver

Second, create a dynamic object resolver and append the found ID from the runtime data pool.

form_builder.output_workflow.object.dynamic_object_resolver.event:
    class: FormBuilderBundle\OutputWorkflow\DynamicObjectResolver\ObjectByRuntimeDataResolver
    autowire: true
    arguments:
        $runtimeDataId: 'event_id'
        $objectIdentifier: 'name'
        $isLocalizedValue: false
    tags:
        - { name: form_builder.output_workflow.object.dynamic_resolver, identifier: 'event', label: 'My Event Object Resolver'}