Support

Account

Home Forums Gutenberg Required fields in Gutenberg editor

Solving

Required fields in Gutenberg editor

  • Maybe (actually, quite probably) I’m doing it wrong, but so far I haven’t been able to coax any field to be required while using the Gutenberg editor (WordPress 5 Beta 4), if the fieldset position is not defined as “normal, below content”.

    Is there a way to make a field required if it is to be used in a Gutenberg Block, or as classic metadata in the somewhat more gutenbergy “side” position?

    (BTW, this might complicate things, but being old-fashioned about these kind of things I wouldn’t mind a way to tell an ACF Block to save its data to wp_postmeta instead of the data array inside the blocks html comment).

  • did you maybe find the solution I have the exact same problem, required fields no longer required with Gutenberg enabled

  • Besides putting the required field in the classic below-the-post-content position, nope.
    Haven’t tested ACF Pro 5.8 Beta 3 yet, but I’m not really expecting this to be fixed anyway.

  • thank you philby, I actually thought “classic” meant switching back to classic editor lol, I am going to give the below content position for the fields a try again, thank you!

  • I can’t see this as an open/resolved issue on Github.

    https://github.com/AdvancedCustomFields/acf/issues

    Have a look through the issues. If it’s not on there, might be worth submitting it?

  • The solution I came up with as a fix was to use jquery to disable the publish / update button if the forms on the page don’t validate. It’s only briefly tested so I wouldn’t recommend on a production site without testing.

    Make sure that this script is enqueued via file or is in <script> tags in the admin footer on the gutenberg edit page.

    
    jQuery(document).ready(function($) {
        $(window).bind("load", function () {
            switch_publish_button_on_valid()
        });
        $("form :input").change(function() {
                switch_publish_button_on_valid();
            });
        function switch_publish_button_on_valid(){
            if($('form.metabox-location-normal')[0].checkValidity()){
                $('button.is-primary').removeAttr('disabled');
            } else {
                $('button.is-primary').attr('disabled', 'disabled');
            }
        }
    });
    
  • Has anyone found another solution to this?

    @philby what did you mean by “Besides putting the required field in the classic below-the-post-content position” ?

    My ACF fields are below the post editor (I understand that the fields *inside* of Gutenberg blocks can’t be required https://github.com/AdvancedCustomFields/acf/issues/90). But still when I attempt to publish, I get no errors if the required fields are blank.

    Is that the issue you were experiencing as well?

  • I just had our QA report this same issue. I’ll check the GitHub, hopefully this has a resolution. I hat thinking about having to go back to not using the Block Editor.

  • This is a known issue when using gutenberg editor. As far as I know there is no fix yet from ACF and waiting on any kind of a solution from WP. There is another topic around here somewhere that has the link to the list

    You can also check here https://www.advancedcustomfields.com/resources/known-issues/

    And I found the other link as well https://github.com/WordPress/gutenberg/issues/12692

  • Are there any updates or workarounds available? The “known-issues” page says in “Field validation does not work in Gutenberg” that there is a fix scheduled for ACF 5.8. but I still got the same issue.

  • Bump — just curious if there’s been any progress on this deficiency?

    Thanks!

  • Would also be interested in a solution for that issue 🙂

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

You must be logged in to reply to this topic.