Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from 1.13 to 1.14.x breaks ACF fields #62

Open
visahakkarainen opened this issue Nov 30, 2018 · 0 comments
Open

Upgrade from 1.13 to 1.14.x breaks ACF fields #62

visahakkarainen opened this issue Nov 30, 2018 · 0 comments

Comments

@visahakkarainen
Copy link

When upgrading to 1.14.x from 1.13 I noticed that conditional logic and format_value method stopped working. There might even be more things that have broken when I upgraded but those are the two things I noticed.

My conditional logic on my project looks like this:

        // Radio buttons
        $product_type = ( new Field\Radio( __( 'Type', 'the-dustpress-theme' ) ) )
            ->set_key( $key . '_product_card_type' )
            ->set_name( 'product_card_type' )
            ->add_choice( __( 'Product', 'the-dustpress-theme' ), 'product' )
            ->add_choice( __( 'Category', 'the-dustpress-theme' ), 'category' )
            ->set_required();
        $this->add_field_before( $product_type, 'list' );

        // Conditional logic based on radio buttons
        $cond_logic_product = ( new ConditionalLogicGroup() )
            ->add_rule( $product_type, '==', 'product' );

        $cond_logic_category = ( new ConditionalLogicGroup() )
            ->add_rule( $product_type, '==', 'category' );

        // Get repeater field and add conditional logic for the whole card field area inside repeater
        $repeater = $this->get_field( 'list' );
        $card_automatic = $repeater->get_field( 'card_automatic' );
        $card_automatic->add_conditional_logic( $cond_logic_product );

        // New cards field used when adding terms
        $autom_card_args = [
            'use_card_style' => $this->use_card_style,
            'card_taxonomy'  => $this->card_taxonomy,
            'use_taxonomy'   => $this->use_taxonomy,
        ];

        $category_cards = new CardAutomatic( $this->card_label, $key . '_prod_term', 'prod_term', $autom_card_args );
        $category_cards->set_wrapper_classes( 'geniem-acf-inline' )
            ->add_conditional_logic( $cond_logic_category );
        $repeater->add_field( $category_cards );

format_value stopped working when code looked like this:

        // Video embed url
        $url = ( new Field\Url( __( 'Url of the video as a whole (Youtube or Vimeo)', 'the-dustpress- 
        theme' ) ) )
            ->set_key( $this->key . '_url' )
            ->set_name( 'url' )
            ->set_required();
        $this->add_field( $url );

        $this->format_value( [ $this, 'format_video_url' ] );

I had to move format_value to $url variable in order to get it to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant