public function AssetMoveActionForm::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/
core/ location/ src/ Form/ AssetMoveActionForm.php, line 129
Class
- AssetMoveActionForm
- Provides an asset move confirmation form.
Namespace
Drupal\farm_location\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['location'] = [
'#type' => 'entity_autocomplete',
'#title' => $this
->t('Location'),
'#target_type' => 'asset',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'farm_location_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 movement has taken place (mark the log as done)'),
];
return parent::buildForm($form, $form_state);
}