I am creating a form to collect data for a specific content type which has a field collection in it.

So basically I am creating nodes manually through form API. What I need to do is to add a field collection table to my form which corresponds to the field collection I declared in the node type.

I have got how the table is rendered in the original add content form, which is like this:

[field_student_grades] => Array
        [#type] => container
        [#attributes] => Array
                [class] => Array
                        [0] => field-type-field-collection
                        [1] => field-name-field-student-grades
                        [2] => field-widget-field-collection-table


        [#weight] => 5
        [#tree] => 1
        [#language] => und
        [und] => Array
                [0] => Array
                        [#entity_type] => field_collection_item
                        [#entity] => FieldCollectionItemEntity Object
                                [fieldInfo:protected] => 
                                [hostEntity:protected] => stdClass Object
                                        [uid] => 1

But I do not know how to deal with the [und] and [hostEntity:protected] and stdClass Object in code.

1 Answer 1


You can't access Protected members directly.

you'll need to extend the class that represents that object to provide getter methods for the protected properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.