htmlburger/carbon-fields

Unable to update page because of hidden required fields.

dtracey-fi opened this issue · 2 comments

Version

  • Carbon Fields: 3.6.3
  • WordPress: 6.4.1
  • PHP: 8.0.30

Expected Behavior

Should be able to update the content as the fields do not pertain to the home page template.

Actual Behavior

You are unable to update the home page content, as the Update button is greyed and and cannot be clicked.

Container definition

 Container::make('post_meta', 'State Details')
            ->where('post_template', '=', 'page-landing.php')
            ->add_fields([
                Field::make('text', 'state_phone', __('State Phone Number', $this->text_domain))
                    ->set_width(50)
                    ->set_required(true)
                    ->set_attribute('placeholder', '2222 2222')
                    ->set_help_text('The phone number label for the hero meta box.'),
                Field::make('image', 'state_logo', __('State Logo', $this->text_domain))
                    ->set_width(100)
                    ->set_required(true)
                    ->set_help_text('The logo to show in the hero meta box.'),
            ]);

Steps to Reproduce the Problem

  1. Edit a page that doesn't use the template 'page-landing.php'
  2. Update button will be greyed out.

Steps to Temporarily resolve the Problem

  1. Select "Screen Options" on the top of the page editor.
  2. Tick the "State Details" option.
  3. Fill in the required "State Details" fields.
  4. The Update button will now be active.

Comments

When editing the home page template, or any other page that isn't using the 'page-landing.php' template, the Update button is greyed out, the fix is to show the "State details" fields in the "Screen Options" section and fill in the required fields.