Calculated field - string from different input-fields


#1

Hey, my scenario is as following.

I got a class with input fields (foo, bar, baz.), and want to create a string from these fields.
e.g. fields “foo” and “bar” should save in “baz” as “foobar”. After “foo” and “bar” is set, “baz” should be automatically set to “foobar”, and It does not matter if foo or bar is not set.

The question: what is a smart & clean way to do this, with a calculated field “baz”?

Thank you


#2

Assuming you wqant this to happen when editing objects in Pimcore admin you could create the baz field as non-editable then on save you could hook into the event system to set the value of baz from foo and bar:

Create an event listener or subscriber and listen for the PRE_ADD and PRE_UPDATE events


#3

Hi,
I would go for a calculated field.

BR
Christian


#4

thank you,

calculated field works simple and good!

cheers