Object of class Foo\Bar could not be converted to int
This post has NOT been accepted by the mailing list yet.
This post was updated on .
I have a form with a MultiCheckBox element protocols.
The structure of the form duplicates the structure of an object of type Foo ('use_as_base_fieldset' => true): every primitive Element relates to a primitive property, every Fieldset relates to a property of a complex type, every Collection relates to an array property with complex types.
The Elementprotocols (of the fieldset endpoint) relates to the property protocols of the class Endpoint, but this property is an array with objects of type Protocol (not an array with IDs). That means, the object, the form returns, is not complete -- I have to transform the protocol values to Protocol objects before saving it. It's not nice, but it works and I haven't found a more elegant solution. (Btw.: Is there a better solution for this?)
The current issue occurs on binding a saved object to the form (in order to edit an existing entry):
Notice: Object of class My\DataObject\Protocol could not be converted to int in /var/www/path/to/project/vendor/zendframework/zend-form/src/View/Helper/FormMultiCheckbox.php on line 202
My interpretation of this is, that the MultiCheckBox expects an array with values as primitive types (e.g. int). Instead it gets an array with objects (of type Protocol) and tries to use its values for in_array(...) -- and that cannot work.
I don't think it's a very exotic problem. But I could not find any solution.