Symfony 2.8
I have a form:
$builder->add('name', TextType::class);
$builder->add('contacts', CollectionType::class, [...]);
The normalizer produces this output:
stdClass Object
(
[name] => Test
[contacts] => stdClass Object
(
[0] => stdClass Object
(
[value] => TestValue
)
)
)
instead of:
stdClass Object
(
[name] => Test
[contacts] => Array <--------- array
(
[0] => stdClass Object
(
[value] => TestValue
)
)
)
I'm passing this data to a JS in this way inside <script> in .twig:
window.form.initialValues = {{ initialValues|json_encode|raw }}
stdClass and Array are different in JSON format. stdClass gives {0: item} instead of [item].
As a result I have error while using liform-react in ConnectedFieldArray.js:83
nextValue.every is not a function
When I hardcoded StdClass -> Array conversion, all works
$initialValues->contacts = json_decode(json_encode($initialValues->contacts), true);
Symfony 2.8
I have a form:
The normalizer produces this output:
instead of:
I'm passing this data to a JS in this way inside
<script>in.twig:stdClass and Array are different in JSON format. stdClass gives
{0: item}instead of[item].As a result I have error while using
liform-reactinConnectedFieldArray.js:83When I hardcoded StdClass -> Array conversion, all works