You are a developer and looking for Shopware projects?
Apply Now!
setErrorBubbling example
protected
function
getForm
(
$name
= 'name',
$propertyPath
= null,
$dataClass
= null,
$errorMapping
=
[
]
,
$inheritData
= false,
$synchronized
= true, array
$options
=
[
]
)
{
$config
=
new
FormConfigBuilder
(
$name
,
$dataClass
,
$this
->dispatcher,
[
'error_mapping' =>
$errorMapping
,
]
+
$options
)
;
$config
->
setMapped
(
$options
[
'mapped'
]
?? true
)
;
$config
->
setInheritData
(
$inheritData
)
;
$config
->
setPropertyPath
(
$propertyPath
)
;
$config
->
setCompound
(
true
)
;
$config
->
setDataMapper
(
new
DataMapper
(
)
)
;
$config
->
setErrorBubbling
(
$options
[
'error_bubbling'
]
?? false
)
;
if
(
!
$synchronized
)
{
$config
->
addViewTransformer
(
new
CallbackTransformer
(
static
fn
(
$normData
)
=>
$normData
,
static
fn
(
)
=>
throw
new
TransformationFailedException
(
)
)
)
;
}
return
new
Form
(
$config
)
;
}
/** * @return void */
public
function
buildForm
(
FormBuilderInterface
$builder
, array
$options
)
{
parent::
buildForm
(
$builder
,
$options
)
;
$isDataOptionSet
= \
array_key_exists
(
'data',
$options
)
;
$builder
->
setRequired
(
$options
[
'required'
]
)
->
setErrorBubbling
(
$options
[
'error_bubbling'
]
)
->
setEmptyData
(
$options
[
'empty_data'
]
)
->
setPropertyPath
(
$options
[
'property_path'
]
)
->
setMapped
(
$options
[
'mapped'
]
)
->
setByReference
(
$options
[
'by_reference'
]
)
->
setInheritData
(
$options
[
'inherit_data'
]
)
->
setCompound
(
$options
[
'compound'
]
)
->
setData
(
$isDataOptionSet
?
$options
[
'data'
]
: null
)
->
setDataLocked
(
$isDataOptionSet
)
->
setDataMapper
(
$options
[
'compound'
]
?
$this
->dataMapper : null
)
->
setMethod
(
$options
[
'method'
]
)
->
setAction
(
$options
[
'action'
]
)
;