Support

Account

Home Forums Front-end Issues Can't display on front-end more than one field group with date picker field Reply To: Can't display on front-end more than one field group with date picker field

  • Hello Carlos! It took me a long time because I’m not an expert in code but, yes, I solved it. I don’t know if the solution I’ve found is the best, since I have modified some plugin source files that will be overwritten when updating, but for now it works!
    I’m glad to show you how I did it hoping that you find it useful.

    The problem is that the acf_form function surrounds the acf form with a <div id=“poststuff”> wrapper, and calling it twice will create two wrappers with this same id, and confuse the javascript.
    Maybe if you remove the addition of this wrapper from the acf_form() code, then wrap the fields manually it may work, but in my case I have too many forms in the same page and this solution would be impossible for me…. So here what I have done:

    – advanced-custom-fields / core / api.php
    LINE 1251 : <! - <div Id="poststuff"> ->
    LINE 1269 : enter here the div above together with the variable that stored the id of “group_fields” + class to use with the css styles:
    echo ' <div id="poststuff_' . $acf['id'] . '" class="stuffclass"> ' ;

    – advanced-custom-fields / js / input.js
    LINE 917 : change the absolute reference to the div “#poststuff” with the selector “all divs that start with “poststuff_”:
    $(document).trigger('acf/setup_fields', [ $("[id^='poststuff_']") ]);

    – advanced-custom-fields / js / input.min.js
    generated the new compressed code

    – advanced-custom-fields / css / input.css
    ROW 16 : Replaced reference id “#poststuff ” with reference class “.stuffclass”

    	.acf_postbox .inside,
    	.stuffclass .acf_postbox .inside {
    	margin: 0;
    	padding: 0;
    	}

    That’s all!
    If someone has a better solution or any further suggestions these would be well-accepted! 😉