wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

Repeater in repeater issues #197

Closed richardsweeney closed 8 years ago

richardsweeney commented 8 years ago

The issue remains!!

The values are saved correctly to the database, but the values displayed in the meta box are incorrect. The values in the 2nd field are replaced by that by the values from the 1st field.

<?php
class Products_Page_Type extends Papi_Page_Type {

/**
 * The type meta options.
 *
 * @return array
 */
public function meta() {
    return [
        'name'        => __( 'Products Page Type', 'gram' ),
        'description' => __( "The page type for the products page", 'gram' ),
        'post_type'   => 'page',
    ];
}

/**
 * Register content meta box.
 */
public function register() {
    $this->box( __( 'Products', 'gram' ), [ $this, 'products_section' ] );
}

public function products_section() {
    return papi_property( [
        'title'    => __( 'Products repeater', 'gram' ),
        'slug'     => 'products_section',
        'type'     => 'repeater',
        'settings' => [
            'layout'        => 'row',
            'add_new_label' => __( 'Add new product category', 'gram' ),
            'items'         => [
                papi_property( [
                    'title' => __( 'Category Name', 'gram' ),
                    'type'  => 'string',
                    'slug'  => 'product_category',
                ] ),
                papi_property( [
                    'title' => __( 'Category Image', 'gram' ),
                    'type'  => 'image',
                    'slug'  => 'product_image',
                ] ),
                papi_property( [
                    'title'    => __( 'Products list', 'gram' ),
                    'type'     => 'repeater',
                    'slug'     => 'products_repeater',
                    'settings' => [
                        'add_new_label' => __( 'Add new product', 'gram' ),
                        'items'         => [
                            papi_property( [
                                'title' => __( 'Product', 'gram' ),
                                'type'  => 'string',
                                'slug'  => 'product',
                            ] ),
                        ],
                    ],
                ] ),
            ],
        ],
    ] );
}

}
richardsweeney commented 8 years ago

This is not fixed by https://github.com/wp-papi/papi/commit/a03c048f5a9e7fd895e267b61f8bb293fe1b872f

frozzare commented 8 years ago

Have you tested against 3.x branch since it's the next stable version going out? Master branch is unstable and contains version 3.2 that isn't released yet.

I can't reproduce this in 3.x branch.

richardsweeney commented 8 years ago

This works on the the 3.x branch. Wahoo!!