public function PriceListForm::buildForm in Commerce Pricelist 8
Same name and namespace in other branches
- 8.2 src/Form/PriceListForm.php \Drupal\commerce_pricelist\Form\PriceListForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityForm::buildForm
File
- src/
Form/ PriceListForm.php, line 73
Class
- PriceListForm
- Form controller for Price list edit forms.
Namespace
Drupal\commerce_pricelist\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\commerce_pricelist\Entity\PriceList */
$store_query = $this->entityManager
->getStorage('commerce_store')
->getQuery();
if ($store_query
->count()
->execute() == 0) {
$link = Link::createFromRoute('Add a new store.', 'entity.commerce_store.add_page');
$form['warning'] = [
'#markup' => t("Products can't be created until a store has been added. @link", [
'@link' => $link
->toString(),
]),
];
return $form;
}
return parent::buildForm($form, $form_state);
}