jengalas
5/6/2014 - 12:01 AM

Fix for wp-types "invalid argument supplied for foreach()" error. Forms.php is found in wp-types/embedded/classes/ Form-child.php is found

Fix for wp-types "invalid argument supplied for foreach()" error.

Forms.php is found in wp-types/embedded/classes/

Form-child.php is found in wp-types/embedded/classes/relationships/

public function renderElements( $elements )
    {
        $output = '';
        if ( $elements)
            {
            foreach ( $elements as $key => $element ) {
                if ( !isset( $element['#type'] )
                        || !$this->_isValidType( $element['#type'] ) ) {
                    continue;
                }
                if ( $element['#type'] != 'fieldset' ) {
                    $output .= $this->renderElement( $element );
                } else if ( isset( $element['#type'] )
                        && $element['#type'] == 'fieldset' ) {
                    $buffer = $this->renderElements( $element );
                    $output .= $this->fieldset( $element, 'wrap', $buffer );
                } else if ( is_array( $element ) ) {
                    $output .= $this->renderElements( $element );
                }
            }
            return $output;
        }
    }
function __filter_meta_form( $form = array() ) {
        if ( $form )
            {
            foreach ( $form as $k => &$e ) {
                /*
                 *
                 * Filter name
                 */
                if ( isset( $e['#name'] ) ) {
                    $e['#name'] = $this->cf->alter_form_name( 'wpcf_post_relationship['
                            . $this->parent->ID . ']', $e['#name'] );
                }
                /*
                 * Some fields have #options and names set there.
                 * Loop over them and adjust.
                 */
                if ( !empty( $e['#options'] ) ) {
                    foreach ( $e['#options'] as $_k => $_v ) {
                        if ( isset( $_v['#name'] ) ) {
                            $e['#options'][$_k]['#name'] = $this->alter_form_name( $_v['#name'] );
                        }
                    }
                }
                if ( isset( $e['#title'] ) ) {
                    unset( $e['#title'] );
                }
                if ( isset( $e['#description'] ) ) {
                    unset( $e['#description'] );
                }
                $e['#inline'] = true;
            }

            return $form;
        }
    }