public function AssetGroupActionForm::buildForm in farmOS 2.x
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 ConfirmFormBase::buildForm
File
- modules/
asset/ group/ src/ Form/ AssetGroupActionForm.php, line 129
Class
- AssetGroupActionForm
- Provides an asset group confirmation form.
Namespace
Drupal\farm_group\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$this->entityType = $this->entityTypeManager
->getDefinition('asset');
$this->entities = $this->tempStore
->get($this->user
->id());
if (empty($this->entityType) || empty($this->entities)) {
return new RedirectResponse($this
->getCancelUrl()
->setAbsolute()
->toString());
}
$form['date'] = [
'#type' => 'datelist',
'#title' => $this
->t('Date'),
'#default_value' => new DrupalDateTime(),
'#date_part_order' => [
'year',
'month',
'day',
],
'#date_year_range' => '-15:+15',
'#required' => TRUE,
];
$form['group'] = [
'#type' => 'entity_autocomplete',
'#title' => $this
->t('Group'),
'#description' => $this
->t('The groups to assign the asset to. Leave blank to un-assign an asset from groups.'),
'#target_type' => 'asset',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'farm_group_reference',
'display_name' => 'entity_reference',
],
'match_operator' => 'CONTAINS',
'match_limit' => 10,
],
'#tags' => TRUE,
'#validate_reference' => FALSE,
'#maxlength' => 1024,
];
$form['done'] = [
'#type' => 'checkbox',
'#title' => $this
->t('This membership change has taken place (mark the log as done)'),
];
return parent::buildForm($form, $form_state);
}