Skip to content

Commit

Permalink
Reformat Planting quick form log field info arrays. No functional cha…
Browse files Browse the repository at this point in the history
…nge.

This will make it easier to use a new buildInlineContainer()
method for quantity fields provided by the next commit.
  • Loading branch information
mstenta committed Apr 1, 2023
1 parent 5ada077 commit aa35c2c
Showing 1 changed file with 56 additions and 57 deletions.
113 changes: 56 additions & 57 deletions modules/quick/planting/src/Plugin/QuickForm/Planting.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,67 +328,66 @@ protected function buildLogForm(string $log_type, array $include_fields = [], ar
}

// Create log fields.
$field_info = [
'date' => [
'#type' => 'datetime',
'#title' => $this->t('Date'),
'#default_value' => new DrupalDateTime('midnight', $this->currentUser->getTimeZone()),
'#required' => TRUE,
],
'done' => [
'#type' => 'checkbox',
'#title' => $this->t('Completed'),
],
'location' => [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Location'),
'#description' => $this->t('Where does this take place?'),
'#target_type' => 'asset',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'farm_location_reference',
'display_name' => 'entity_reference',
'arguments' => [],
],
'match_operator' => 'CONTAINS',
$field_info = [];
$field_info['date'] = [
'#type' => 'datetime',
'#title' => $this->t('Date'),
'#default_value' => new DrupalDateTime('midnight', $this->currentUser->getTimeZone()),
'#required' => TRUE,
];
$field_info['done'] = [
'#type' => 'checkbox',
'#title' => $this->t('Completed'),
];
$field_info['location'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Location'),
'#description' => $this->t('Where does this take place?'),
'#target_type' => 'asset',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'farm_location_reference',
'display_name' => 'entity_reference',
'arguments' => [],
],
'#required' => TRUE,
'match_operator' => 'CONTAINS',
],
'quantity' => [
'#type' => 'container',
'#attributes' => [
'class' => ['inline-container'],
],
'value' => [
'#type' => 'textfield',
'#title' => $this->t('Quantity'),
'#size' => 16,
],
'units' => [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Units'),
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
'target_bundles' => ['unit'],
],
'#autocreate' => [
'bundle' => 'unit',
],
'#size' => 16,
],
'measure' => [
'#type' => 'select',
'#title' => $this->t('Measure'),
'#options' => $filtered_quantity_measure_options,
'#default_value' => 'weight',
],
'#required' => TRUE,
];
$field_info['quantity'] = [
'#type' => 'container',
'#attributes' => [
'class' => ['inline-container'],
],
];
$field_info['quantity']['value'] = [
'#type' => 'textfield',
'#title' => $this->t('Quantity'),
'#size' => 16,
];
$field_info['quantity']['units'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Units'),
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
'target_bundles' => ['unit'],
],
'notes' => [
'#type' => 'text_format',
'#title' => $this->t('Notes'),
'#format' => 'default',
'#autocreate' => [
'bundle' => 'unit',
],
'#size' => 16,
];
$field_info['quantity']['measure'] = [
'#type' => 'select',
'#title' => $this->t('Measure'),
'#options' => $filtered_quantity_measure_options,
'#default_value' => 'weight',
];
$field_info['notes'] = [
'#type' => 'text_format',
'#title' => $this->t('Notes'),
'#format' => 'default',
];
foreach ($include_fields as $field) {
if (array_key_exists($field, $field_info)) {
Expand Down

0 comments on commit aa35c2c

Please sign in to comment.