Support

Account

Home Forums Backend Issues (wp-admin) ACF Felder (Gruppe) im Backend / Modal

Solving

ACF Felder (Gruppe) im Backend / Modal

  • Hallo zusammen,
    ich versuche im WordPress-Backend eine acf_form zu laden, die jedoch in einem MODAL angezeigt wird. Sprich ich habe ein Button gemacht – und wenn ich den Klicke öffnet sich ein MODAL Fenster.

    Das klappt auch soweit.. Textfelder kann ich bearbeiten und speichern. Aber der Bilder-Upload funktioniert nicht.. hat jemand eine idee?

    Hier mal der Code:

    function create_acf_form() {
    	ob_start();	
    	wp_localize_script( 'my-ajax-script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    	wp_enqueue_media();	
        acf_enqueue_scripts();
        acf_form_head();
    	$post_id = id_finder();
        if (!$post_id) {
            return 'Kein Post gefunden.'; 
        }
        $field_group_name = 'group_655c9ef91419b';
        $field_group = acf_get_field_group($field_group_name);
    
        $options = array(
            'field_groups' => array($field_group['ID']),
            'post_id' => $post_id,
            'submit_value' => __('Speichern', 'test-projekt'), 
            'return' => '/wp-admin/post.php?post=' . $post_id . '&action=edit&classic-editor',
        );
        acf_form($options);
        $ret = ob_get_contents();
        ob_end_clean();
        return $ret;
    }

    Damit erstelle ich die FORM und mit <?php echo create_acf_form(); ?> lade ich die form dann im modal..

    Freue mich über ideen! 😀

  • acf_form_head() must be called before any output is created on the page. Calling it in your function means that page content has already been generated.

    I’m not sure any of the other stuff you’re doing will work either. ACF does all of that initialization when you call acf_form_head() and like I said, this must be called before html output is started.

    https://www.advancedcustomfields.com/resources/acf_form_head/

  • Hi John,

    I don’t think that’s the problem, because it loads the form.
    And since it’s all in the backend, that shouldn’t be a problem.

    My guess is:
    I want to develop my own module for the AVIA builder from ENFOLD (using their shortcode).

    And the POPUP is already delivered and opened by them. Apart from the images and a few other modules, it also works.

    Do you have any other ideas?
    I can also send you the access, that’s no problem…

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.