DashboardEditForm.php in Draggable dashboard 8
File
src/Form/DashboardEditForm.php
View source
<?php
namespace Drupal\draggable_dashboard\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\draggable_dashboard\Entity\DashboardEntity;
class DashboardEditForm extends DashboardFormBase {
public function getFormId() {
return 'draggable_dashboard_edit';
}
protected function buildDashboard($did) {
return DashboardEntity::load($did);
}
public function buildForm(array $form, FormStateInterface $form_state, $did = NULL) {
$form = parent::buildForm($form, $form_state, $did);
$form['#title'] = $this->dashboard
->get('title');
$form['did'] = [
'#type' => 'hidden',
'#value' => $this->dashboard
->id(),
];
$url = new Url('draggable_dashboard.delete_dashboard', [
'did' => $this->dashboard
->id(),
]);
$form['actions']['delete'] = [
'#type' => 'link',
'#title' => $this
->t('Delete'),
'#url' => $url,
'#attributes' => [
'class' => [
'button',
'button--danger',
],
],
];
return $form;
}
}