Attached is the array created by drupal_get_form (printed with print_r) for a simple set of checkboxes made using the options widget. Also attached is the HTML produced by running drupal_render against the form array.

Notice that the array (check_form.txt) is 995 lines, while the actual HTML form (check_render.txt) is 23 lines. I have a lot to say, but the fact that a simple set ofcheckboxes made with the options widget creates a form array of nearly 1,000 lines almost speaks for itself.

This came out of some work I was doing for #569542: Button Option Field is Required, has One Option - Select that Option. There were some failed test cases (which seem to be caused by field_update_field not working) I was diagnosing when I came across this.

CommentFileSizeAuthor
check_render.txt1.79 KBMike Wacker
check_form.txt34.48 KBMike Wacker

Comments

bjaspan’s picture

Status: Active » Closed (won't fix)

Very little of this is related to Field API; it is just a by-product of the way Form API works. Consider: The following part of the form structure turns into *nothing* in the rendered output, yet is a critical part of the form:

    [fttype] => Array
        (
            [#type] => value
            [#value] => test_bundle
            [#tree] => 
            [#parents] => Array
                (
                    [0] => fttype
                )

            [#array_parents] => Array
                (
                    [0] => fttype
                )

            [#weight] => 0.002
            [#processed] => 
            [#description] => 
            [#title] => 
            [#attributes] => Array
                (
                )

            [#required] => 
            [#attached] => Array
                (
                )

            [#input] => 1
            [#defaults_loaded] => 1
            [#id] => edit-fttype-6
            [#name] => fttype
            [#sorted] => 1
            [#children] => 
            [#printed] => 1
        )

The next excerpt turns into, approximately, "<input type="hidden" name="form_build_id" "value"="form-8686652c810fe391fabeaff03fae46bd" id="form-8686652c810fe391fabeaff03fae46bd" />>":

    [form_build_id] => Array
        (
            [#type] => hidden
            [#value] => form-8686652c810fe391fabeaff03fae46bd
            [#id] => form-8686652c810fe391fabeaff03fae46bd
            [#name] => form_build_id
            [#tree] => 
            [#parents] => Array
                (
                    [0] => form_build_id
                )

            [#array_parents] => Array
                (
                    [0] => form_build_id
                )

            [#weight] => 0.006
            [#processed] => 1
            [#description] => 
            [#title] => 
            [#attributes] => Array
                (
                )

            [#required] => 
            [#attached] => Array
                (
                )

            [#input] => 1
            [#process] => Array
                (
                    [0] => ajax_process_form
                )

            [#theme] => hidden
            [#defaults_loaded] => 1
            [#sorted] => 1
            [#children] => <input type="hidden" name="form_build_id" id="form-8686652c810fe391fabeaff03fae46bd" value="form-8686652c810fe391fabeaff03fae46bd"  />

            [#printed] => 1
        )

This is not a bug.