You are here

public static function ProductForm::hideEmptyVisibilitySettings in Commerce Core 8.2

Hides the visibility settings if the stores widget is a hidden element.

Parameters

array $form: The form.

Return value

array The modified visibility_settings element.

File

modules/product/src/Form/ProductForm.php, line 193

Class

ProductForm
Defines the product add/edit form.

Namespace

Drupal\commerce_product\Form

Code

public static function hideEmptyVisibilitySettings(array $form) {
  if (isset($form['stores']['widget']['target_id'])) {
    $stores_element = $form['stores']['widget']['target_id'];
    if (!Element::getVisibleChildren($stores_element)) {
      $form['visibility_settings']['#printed'] = TRUE;

      // Move the stores widget out of the visibility_settings group to
      // ensure that its hidden element is still present in the HTML.
      unset($form['stores']['#group']);
    }
  }
  return $form;
}