Skip to content

Conflict with Yoast #857

@filipac

Description

@filipac

Version

  • Carbon Fields: 3.1.14
  • WordPress: 5.3.2
  • PHP: 7.3

Expected Behavior

When Yoast seo plugin is active, I should be able to delete, close or duplicate a complex section.

Actual Behavior

When clicking any button, for example the duplicate button on the section, you get an JS error.

react-dom.js?ver=16.9.0:481 Uncaught TypeError: Cannot read property 'fields' of undefined
    at getFieldsFromFieldsHolder (index.js:43)

Container definition

Container::make('post_meta', __('Page Builder', 'crb'))
            ->where('post_type', '=', 'page')

            ->add_fields(array(
                Field::make('complex', 'crb_sections', 'Builder')
                    //bootstrap rows and columns
                    ->add_fields(
                        'rich_text_section',
                        'Text Section',
                        array(
                            Field::make('complex', 'row_type', 'Section')
                                ->add_fields('text1col', '1 Column Row', array(
                                    Field::make('rich_text', 'text', 'Text')
                                ))
                                ->add_fields('text2col', '2 Column Row', array(
                                    Field::make('rich_text', 'text_col1', 'Text Column 1')->set_width(50),
                                    Field::make('rich_text', 'text_col2', 'Text Column 2')->set_width(50)
                                ))
                                ->add_fields('text3col', '3 Column Row', array(
                                    Field::make('rich_text', 'text_col1', 'Text Column 1')->set_width(30),
                                    Field::make('rich_text', 'text_col2', 'Text Column 2')->set_width(30),
                                    Field::make('rich_text', 'text_col3', 'Text Column 3')->set_width(30)
                                )),
                            Field::make('radio', 'breakpoint', 'Breakpoint')
                                ->add_options(array(
                                    '0' => 'md',
                                    '1' => 'lg',
                                ))->set_width(50),
                        )
                    )
                    // Manually selected posts in a grid

                    ->add_fields('statistics', 'Statistics section', array(
                        Field::make('complex', 'row_type', 'Section')
                            ->add_fields('text1col', 'Statistic', array(
                                Field::make('text', 'text_1', 'Value'),
                                Field::make('text', 'header_1', 'Title')
                            ))->set_max(4)->set_min(1)
                    ))
                    //Contact Us Section with custom heading
                    ->add_fields('contact', 'Contact Us Section', array(
                        Field::make('image', 'image_text_image', 'Image')
                            ->set_value_type('url')
                            ->set_width(50),

                        Field::make('radio', 'image_animations', 'Image Animations')
                            ->add_options(array(
                                '0' => 'Disabled',
                                '1' => 'Enabled',
                            ))->set_width(50),
                        Field::make('text', 'contact_title', 'Title'),
                        Field::make('text', 'contact_brand', 'Heading'),
                        Field::make('rich_text', 'contact_details', 'Text')
                            ->set_value('[TEL]: 905-641-0309<br/>[FAX]: 905-641-1343'),
                        Field::make('select', 'contact_type', 'Contact Form')
                            ->add_options($cf7array)->set_width(50),


                    ))

                    //Simple CTA Section with custom heading
                    ->add_fields('simple_cta', 'Simple CTA Section', array(
                        $colors,
                        Field::make('radio', 'border_top', 'Border Top')
                            ->add_options(array(
                                '0' => 'Disabled',
                                '1' => 'Enabled',
                            ))->set_width(50),

                        Field::make('text', 'heading', 'Heading'),
                        Field::make('text', 'text', 'Text'),
                        $buttons
                    ))

                    //Simple BANNER Section with custom text and logo
                    ->add_fields('simple_banner', 'Simple BANNER Section', array(
                        $colors,
                        Field::make('image', 'image_text_image', 'Image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('text', 'text', 'Text')->set_value('THE WELLAND CANAL WILL CREATE <span class="text-yellow">85,000 JOBS</span> THROUGH REAL ESTATE SERVICES AVAILABLE'),
                        $buttons
                    ))

                    //HERO Section with custom text and image
                    ->add_fields('hero', 'Hero Section', array(
                        Field::make('image', 'image_text_image', 'Background Image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('image', 'image_main_image', 'Foreground Image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('text', 'text_1', 'Heading'),
                        Field::make('textarea', 'text_2', 'Subtitle'),

                        Field::make('radio', 'text_location', 'Text Location')
                            ->add_options(array(
                                '0' => 'Bottom Left (Default)',
                                '1' => 'Bottom Right',
                                '2' => 'Top Left',
                                '3' => 'Top Right',
                                '4' => 'Center',
                                '5' => 'Top Center',
                                '6' => 'Bottom Center',
                            )),
                    ))

                    //Image and Text with CTA
                    ->add_fields('image_text_cta', 'Image/Text CTA', array(
                        Field::make('image', 'image_text_image', 'Image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('file', 'image_p_image', 'Paragraph image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('radio', 'image_text_image_alignment', 'Image Position')
                            ->add_options(array(
                                'left' => 'Left',
                                'right' => 'Right',
                            ))->set_width(50),
                        Field::make('radio', 'image_reduced_size', 'Reduce image size on mobile')
                            ->add_options(array(
                                '0' => 'Disabled',
                                '1' => 'Enabled',
                            ))->set_width(50),
                        Field::make('radio', 'image_animations', 'Image Animations')
                            ->add_options(array(
                                '0' => 'Disabled',
                                '1' => 'Enabled',
                            ))->set_width(50),


                        Field::make('text', 'image_text_heading', 'Heading'),
                        Field::make('rich_text', 'image_text_content', 'Content'),
                        $buttons
                    ))->set_width(50)
                    //Image and Text with CTA
                    ->add_fields('image_text_cta_big', 'Image/Text CTA BIG', array(
                        Field::make('image', 'image_text_image', 'Image')
                            ->set_value_type('url')
                            ->set_width(50),
                        Field::make('text', 'image_text_heading', 'Heading'),
                        Field::make('text', 'image_text_heading-2', 'Heading 2'),
                        Field::make('text', 'image_text_heading-3', 'Subheading'),
                        Field::make('rich_text', 'image_text_content', 'Content'),
                        Field::make('radio', 'image_animations', 'Image Animations')
                            ->add_options(array(
                                '0' => 'Disabled',
                                '1' => 'Enabled',
                            ))->set_width(50),
                        $buttons
                    ))->set_width(50)
            ));

Steps to Reproduce the Problem

  1. Install Yoast Wordpress-seo plugin
  2. Copy the container code above
  3. Try to duplicate a section
    image

Comments

Disabling Yoast seo fixes the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions