FlagAddForm.php in Flag 8.4
File
src/Form/FlagAddForm.php
View source
<?php
namespace Drupal\flag\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
class FlagAddForm extends FlagFormBase {
public function buildForm(array $form, FormStateInterface $form_state, $entity_type = NULL) {
$form = parent::buildForm($form, $form_state, $entity_type);
$form['global']['#description'] = $this
->t('The scope cannot be changed once a flag has been saved.');
$form['display']['link_type']['#default_value'] = 'ajax_link';
return $form;
}
public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
$flag = parent::getEntityFromRouteMatch($route_match, $entity_type_id);
$type = $route_match
->getRawParameter('entity_type');
$flag
->setFlagTypePlugin($type);
return $flag;
}
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this
->t('Create Flag');
return $actions;
}
}