acf-builder icon indicating copy to clipboard operation
acf-builder copied to clipboard

display => seamless not working for option page

Open thomasjulienalain opened this issue 5 years ago • 7 comments

Hello !

I created an option page and I want to enable the seamless style. It's not working as expected and still display the metabox.

Seamless is working fine for my other pages, but not for the theme options page. I'm using ACF Builder 1.9 and ACF Pro 5.8.7.

image

namespace App;

use StoutLogic\AcfBuilder\FieldsBuilder;

acf_add_options_page( array(
    'page_title' 	=> 'Gérer les options du site',
    'menu_title'	=> 'Options du site',
    'menu_slug' 	=> 'theme-options',
    'capability'	=> 'edit_others_pages',
    'position'      => 21
) );

$theme_options = new FieldsBuilder('theme_options ', [
    'label' => 'Options du thème',
    'style' => 'seamless'
]);

[...]

return $theme_options;

thomasjulienalain avatar Jan 14 '20 20:01 thomasjulienalain

When you do print_r($theme_options->build()); what is the output?

stevep avatar Jan 14 '20 21:01 stevep

Array
(
    [key] => group_theme_options 
    [title] => Theme Options 
    [label] => Options du thème
    [style] => seamless
    [fields] => Array
        (
            [0] => Array
                (
                    [type] => accordion
                    [name] => accordion_1_accordion
                    [label] => Coordonnées
                    [key] => field_theme_options__accordion_1_accordion
                    [open] => 1
                )

            [1] => Array
                (
                    [type] => textarea
                    [name] => address
                    [label] => Adresse postale
                    [key] => field_theme_options__address
                    [required] => 1
                    [new_lines] => br
                )

            [2] => Array
                (
                    [type] => url
                    [name] => address_gmap
                    [label] => Lien Google Map
                    [key] => field_theme_options__address_gmap
                    [required] => 1
                )

            [3] => Array
                (
                    [type] => text
                    [name] => telephone
                    [label] => Numéro de téléphone
                    [key] => field_theme_options__telephone
                    [required] => 1
                )

            [4] => Array
                (
                    [type] => email
                    [name] => email
                    [label] => Adresse courriel
                    [key] => field_theme_options__email
                    [required] => 1
                )

            [5] => Array
                (
                    [type] => text
                    [name] => fax
                    [label] => Numéro de télécopieur
                    [key] => field_theme_options__fax
                    [required] => 1
                )

            [6] => Array
                (
                    [type] => url
                    [name] => facebook
                    [label] => Lien facebook
                    [key] => field_theme_options__facebook
                    [required] => 1
                )

            [7] => Array
                (
                    [type] => accordion
                    [name] => accordion_1_end_accordion
                    [label] => Accordion 1 End
                    [key] => field_theme_options__accordion_1_end_accordion
                    [endpoint] => 1
                )

            [8] => Array
                (
                    [type] => accordion
                    [name] => accordion_2_accordion
                    [label] => Pied de page
                    [key] => field_theme_options__accordion_2_accordion
                )

            [9] => Array
                (
                    [type] => text
                    [name] => telephone_label
                    [label] => Libellé pour le téléphone
                    [key] => field_theme_options__telephone_label
                    [required] => 1
                    [default_value] => Téléphone
                )

            [10] => Array
                (
                    [type] => text
                    [name] => email_label
                    [label] => Libellé pour le courriel
                    [key] => field_theme_options__email_label
                    [required] => 1
                    [default_value] => Courriel
                )

            [11] => Array
                (
                    [type] => text
                    [name] => address_label
                    [label] => Libellé pour l'adresse postale
                    [key] => field_theme_options__address_label
                    [required] => 1
                    [default_value] => Adresse
                )

            [12] => Array
                (
                    [type] => text
                    [name] => fax_label
                    [label] => Libellé pour le télécopieur
                    [key] => field_theme_options__fax_label
                    [required] => 1
                    [default_value] => Télécopieur
                )

            [13] => Array
                (
                    [type] => text
                    [name] => social_label
                    [label] => Libellé pour les réseaux sociaux
                    [key] => field_theme_options__social_label
                    [required] => 1
                    [default_value] => Nous suivre
                )

            [14] => Array
                (
                    [type] => textarea
                    [name] => company_excerpt
                    [label] => Résumé de l'entreprise
                    [key] => field_theme_options__company_excerpt
                    [required] => 1
                    [new_lines] => br
                )

            [15] => Array
                (
                    [type] => accordion
                    [name] => accordion_2_end_accordion
                    [label] => Accordion 2 End
                    [key] => field_theme_options__accordion_2_end_accordion
                    [endpoint] => 1
                )

        )

    [location] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [param] => options_page
                            [operator] => ==
                            [value] => theme-options
                        )

                )

        )

)


  
  

thomasjulienalain avatar Jan 14 '20 21:01 thomasjulienalain

@thomasjulienalain Hm I'm not sure, it should be working. If you try with the ACF UI, does it work?

stevep avatar Jan 15 '20 02:01 stevep

@stevep Yes it's working with ACF UI. It's really weird.

thomasjulienalain avatar Jan 15 '20 18:01 thomasjulienalain

I assume you are doing this, right?

acf_add_local_field_group($theme_options->build());

wpsmith avatar Jun 02 '20 16:06 wpsmith

Recommend closing as this works @stevep.

wpsmith avatar Jun 02 '20 17:06 wpsmith

Hello ! Yes I use acf_add_local_field_group($theme_options->build()); to load the filds. I am using sage theme.

/**
 * Initialize ACF Builder
 */
add_action('init', function () {
    collect(glob(config('theme.dir').'/app/fields/*.php'))->map(function ($field) {
        return require_once($field);
    })->map(function ($field) {
        if ($field instanceof FieldsBuilder) {
            acf_add_local_field_group($field->build());
        }
    });
});

What I wanted to say is that when I use the ACF plugin in UI mode, the custom group option's title display correctely.

But I still can't make it work with ACF Builder.

thomasjulienalain avatar Jun 03 '20 12:06 thomasjulienalain