public function CatalogSettingsForm::buildForm in Ubercart 8.4
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 ConfigFormBase::buildForm
File
- uc_catalog/
src/ Form/ CatalogSettingsForm.php, line 35
Class
- CatalogSettingsForm
- Configure catalog settings for this site.
Namespace
Drupal\uc_catalog\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('uc_catalog.settings');
$view = Views::getView('uc_catalog');
$view
->initDisplay();
$displays = [];
foreach ($view->displayHandlers as $display) {
if ($display
->getPluginId() == 'page') {
$displays[$display->display['id']] = $display->display['display_title'];
}
}
$form['uc_catalog_display'] = [
'#type' => 'select',
'#title' => $this
->t('Catalog display'),
'#default_value' => $config
->get('display'),
'#options' => $displays,
];
$vid = $config
->get('vocabulary');
if ($vid) {
$catalog = Vocabulary::load($vid);
$form['catalog_vid'] = [
'#prefix' => '<p>',
'#markup' => $this
->t('The taxonomy vocabulary <a href=":edit-url">%name</a> is set as the product catalog.', [
':edit-url' => Url::fromRoute('entity.taxonomy_vocabulary.edit_form', [
'taxonomy_vocabulary' => $catalog
->id(),
])
->toString(),
'%name' => $catalog
->label(),
]),
'#suffix' => '</p>',
];
}
$vocabs = [];
$vocabularies = Vocabulary::loadMultiple();
foreach ($vocabularies as $vid => $vocabulary) {
$vocabs[$vid] = $vocabulary
->label();
}
$form['uc_catalog_vid'] = [
'#type' => 'select',
'#title' => $this
->t('Catalog vocabulary'),
'#default_value' => $config
->get('vocabulary'),
'#options' => $vocabs,
];
$form['uc_catalog_breadcrumb'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display the catalog breadcrumb'),
'#default_value' => $config
->get('breadcrumb'),
];
return parent::buildForm($form, $form_state);
}