Populate checkboxes from array

I have a form, that users have to fill out with their informations. The theme I am using, had this to be a select. I changed it to multi select, as we needed people to be able to select multiple values.

However, after some user testing, we found that many did not know how to select multiple values in a selectbox. So I thought it would be better to make them checkboxes. I’ve been trying to figure out exactly how I could do that, but I can’t seem to figure out how to do this.

<div class="form-option property-type-field-wrapper">
<label for="type"><?php _e( 'Useage', 'framework' ); ?></label>
<span class="selectwrap">
    <select multiple name="type[]" id="type" class="src_select">
        <?php
        if ( inspiry_is_edit_property() ) {
            global $target_property;
            edit_form_hierarchical_options( $target_property->ID, 'property-type' );
        } else {
            ?>
            <?php
            /*
             * Property Type Terms
             */
            $property_types_terms = get_terms( array(
                    'taxonomy'   => "property-type",
                    'orderby'    => 'name',
                    'order'      => 'ASC',
                    'hide_empty' => false,
                    'parent'     => 0
                )
            );
            generate_id_based_hirarchical_options( "property-type", $property_types_terms, - 1 );
        }
        ?>
    </select>
</span>

Anyone who think they might be able to give me a hint?

Read more here: Populate checkboxes from array

Leave a Reply

Your email address will not be published. Required fields are marked *