name = 'loop'; $this->label = __( 'Loop', 'cfs' ); $this->values = array(); } /* ================================================================ html ================================================================ */ function html( $field ) { global $post; $this->values = CFS()->api->get_fields( $post->ID, array( 'format' => 'input' ) ); $this->recursive_clone( $field->group_id, $field->id ); $this->recursive_html( $field->group_id, $field->id ); } /* ================================================================ options_html ================================================================ */ function options_html( $key, $field ) { ?> create_field( array( 'type' => 'true_false', 'input_name' => "cfs[fields][$key][options][row_display]", 'input_class' => 'true_false', 'value' => $this->get_option( $field, 'row_display' ), 'options' => array( 'message' => __( 'Show the values by default', 'cfs' ) ), ) ); ?> create_field( array( 'type' => 'text', 'input_name' => "cfs[fields][$key][options][row_label]", 'value' => $this->get_option( $field, 'row_label', __( 'Loop Row', 'cfs' ) ), ) ); ?> create_field( array( 'type' => 'text', 'input_name' => "cfs[fields][$key][options][button_label]", 'value' => $this->get_option( $field, 'button_label', __( 'Add Row', 'cfs' ) ), ) ); ?> api->get_input_fields( array( 'field_id' => $field_id ) ); // Get sub-fields $results = CFS()->api->get_input_fields( array( 'group_id' => $group_id, 'parent_id' => $field_id ) ); $row_label = $this->dynamic_label( $this->get_option( $loop_field[ $field_id ], 'row_label', __( 'Loop Row', 'cfs' ) ) ); ob_start(); ?>
notes ) ) : ?>

notes; ?>

type ) : $loop_field_ids[] = $field->id; ?> create_field( array( 'type' => $field->type, 'input_name' => "cfs[input][clone][$field->id][value][]", 'input_class' => $field->type, 'options' => $field->options, 'value' => $this->get_option( $field, 'default_value' ), ) ); ?>
recursive_clone( $group_id, $loop_field_id ); } } /* ================================================================ recursive_html ================================================================ */ function recursive_html( $group_id, $field_id, $parent_tag = '', $parent_weight = 0 ) { // Get loop field $loop_field = CFS()->api->get_input_fields( array( 'field_id' => $field_id ) ); // Get sub-fields $results = CFS()->api->get_input_fields( array( 'group_id' => $group_id, 'parent_id' => $field_id ) ); // Dynamically build the $values array $parent_tag = empty( $parent_tag ) ? "[$field_id]" : $parent_tag; eval( "\$values = isset(\$this->values{$parent_tag} ) ? \$this->values{$parent_tag} : false;" ); // Row options $row_display = $this->get_option( $loop_field[ $field_id ], 'row_display', 0 ); $row_label = $this->get_option( $loop_field[ $field_id ], 'row_label', __( 'Loop Row', 'cfs' ) ); $button_label = $this->get_option( $loop_field[ $field_id ], 'button_label', __( 'Add Row', 'cfs' ) ); $css_class = ( 0 < (int) $row_display ) ? ' open' : ''; // Do the dirty work $row_offset = -1; if ( $values ) : foreach ( $values as $i => $value ) : $row_offset = max( $i, $row_offset ); ?>
dynamic_label( $row_label, $results, $values[ $i ] ) ); ?> 
notes ) ) : ?>

notes; ?>

type ) : ?> recursive_html( $group_id, $field->id, "{$parent_tag}[$i][$field->id]", $i ); ?> $field->type, 'input_name' => "cfs[input]{$parent_tag}[$i][$field->id][value][]", 'input_class' => $field->type, 'options' => $field->options, ); if ( isset( $values[ $i ][ $field->id ] ) ) { $args['value'] = $values[ $i ][ $field->id ]; } elseif ( isset( $field->options['default_value'] ) ) { $args['value'] = $field->options['default_value']; } CFS()->create_field( $args ); ?>
name ) { $field = $f; break; } } if ( ! empty( $field ) && isset( $values[ $field->id ] ) ) { if ( 'select' == $field->type ) { $select_key = reset( $values[ $field->id ] ); $row_label = $field->options['choices'][ $select_key ]; } else { $row_label = $values[ $field->id ]; } } elseif ( false !== $fallback ) { $row_label = $fallback; } return $row_label; } /* ================================================================ prepare_value ================================================================ */ function prepare_value( $value, $field = null ) { return $value; } }