Commit 9c8dc939 authored by alexpott's avatar alexpott

Issue #2071485 by tim.plunkett: Modernize action.module forms.

parent eddf21e5
......@@ -64,19 +64,19 @@ public function buildForm(array $form, array &$form_state) {
public function form(array $form, array &$form_state) {
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#title' => $this->t('Label'),
'#default_value' => $this->entity->label(),
'#maxlength' => '255',
'#description' => t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
'#description' => $this->t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
);
$form['id'] = array(
'#type' => 'machine_name',
'#title' => t('Machine name'),
'#title' => $this->t('Machine name'),
'#default_value' => $this->entity->id(),
'#disabled' => !$this->entity->isNew(),
'#maxlength' => 64,
'#description' => t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'),
'#description' => $this->t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'),
'#machine_name' => array(
'exists' => array($this, 'exists'),
),
......@@ -148,7 +148,7 @@ public function submit(array $form, array &$form_state) {
*/
public function save(array $form, array &$form_state) {
$this->entity->save();
drupal_set_message(t('The action has been successfully saved.'));
drupal_set_message($this->t('The action has been successfully saved.'));
$form_state['redirect'] = 'admin/config/system/actions';
}
......
......@@ -7,8 +7,7 @@
namespace Drupal\action\Form;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Action\ActionManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -16,7 +15,7 @@
/**
* Provides a configuration form for configurable actions.
*/
class ActionAdminManageForm implements FormInterface, ControllerInterface {
class ActionAdminManageForm extends FormBase {
/**
* The action plugin manager.
......@@ -64,32 +63,26 @@ public function buildForm(array $form, array &$form_state) {
}
$form['parent'] = array(
'#type' => 'details',
'#title' => t('Create an advanced action'),
'#title' => $this->t('Create an advanced action'),
'#attributes' => array('class' => array('container-inline')),
);
$form['parent']['action'] = array(
'#type' => 'select',
'#title' => t('Action'),
'#title' => $this->t('Action'),
'#title_display' => 'invisible',
'#options' => $actions,
'#empty_option' => t('Choose an advanced action'),
'#empty_option' => $this->t('Choose an advanced action'),
);
$form['parent']['actions'] = array(
'#type' => 'actions'
);
$form['parent']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Create'),
'#value' => $this->t('Create'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
}
/**
* {@inheritdoc}
*/
......
......@@ -18,14 +18,14 @@ class ActionDeleteForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
return t('Are you sure you want to delete the action %action?', array('%action' => $this->entity->label()));
return $this->t('Are you sure you want to delete the action %action?', array('%action' => $this->entity->label()));
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return t('Delete');
return $this->t('Delete');
}
/**
......@@ -42,7 +42,7 @@ public function submit(array $form, array &$form_state) {
$this->entity->delete();
watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label()));
drupal_set_message(t('Action %action was deleted', array('%action' => $this->entity->label())));
drupal_set_message($this->t('Action %action was deleted', array('%action' => $this->entity->label())));
$form_state['redirect'] = 'admin/config/system/actions';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment