protected function All::actionDropdown in SimpleAds 8
Same name in this branch
- 8 src/Form/Ads/All.php \Drupal\simpleads\Form\Ads\All::actionDropdown()
- 8 src/Form/Campaigns/All.php \Drupal\simpleads\Form\Campaigns\All::actionDropdown()
1 call to All::actionDropdown()
- All::buildForm in src/
Form/ Ads/ All.php - Form constructor.
File
- src/
Form/ Ads/ All.php, line 100
Class
- All
- Advertisement listing form.
Namespace
Drupal\simpleads\Form\AdsCode
protected function actionDropdown($form, $types) {
$links = [];
if (count($types) > 1) {
foreach ($types as $id => $name) {
$links[$id] = [
'title' => $this
->t('+ New @name', [
'@name' => $name,
]),
'url' => Url::fromRoute('simpleads.ads.new', [
'type' => $id,
]),
'attributes' => [
'class' => [
'button',
'form-submit',
],
],
];
}
$form['actions']['links'] = [
'#type' => 'dropbutton',
'#links' => $links,
'#prefix' => '<div class="simpleads-actions-wrapper">',
'#suffix' => '</div>',
];
}
else {
foreach ($types as $id => $name) {
$form['actions']['links'] = [
'#type' => 'link',
'#title' => $this
->t('+ New @name', [
'@name' => $name,
]),
'#url' => Url::fromRoute('simpleads.ads.new', [
'type' => $id,
]),
'#attributes' => [
'class' => [
'button',
'button--primary',
'form-submit',
],
],
'#prefix' => '<div class="simpleads-actions-wrapper single">',
'#suffix' => '</div>',
];
}
}
return $form;
}