Skip to content

Commit

Permalink
Add unknown period start+end
Browse files Browse the repository at this point in the history
Closes #74
  • Loading branch information
andrew-gardener committed Jan 9, 2024
1 parent b27c751 commit edcdbdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Form/ItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) : void
'choice_attr' => fn (Period $period, $key, $value) => ['data-year' => $period->getSortableYear()],
'expanded' => false,
'multiple' => false,
'required' => false,
'placeholder' => 'Unknown',
]);
$builder->add('periodEnd', EntityType::class, [
'label' => 'Latest creation',
Expand All @@ -131,6 +133,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) : void
'choice_attr' => fn (Period $period, $key, $value) => ['data-year' => $period->getSortableYear()],
'expanded' => false,
'multiple' => false,
'required' => false,
'placeholder' => 'Unknown',
]);

$builder->add('provenance', Select2EntityType::class, [
Expand Down
6 changes: 3 additions & 3 deletions templates/item/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
{{ dl.make(item, 'dimensions', 'Dimensions') }}
{{ dl.make(item, 'location', 'Location') }}
{{ dl.make(item, 'civilization', 'Culture', 'civilization_show') }}
{% set display_period = [item.periodStart] %}
{% set display_period = [item.periodStart|default('Unknown')] %}
{% if not(item.periodEnd is same as(item.periodStart)) %}
{% set display_period = display_period|merge([item.periodEnd]) %}
{% set display_period = display_period|merge([item.periodEnd|default('Unknown')]) %}
{% endif %}
{{ dl.make({'display': display_period|join('-')|lower}, 'display', "Period") }}
{{ dl.make({'display': display_period|join(' - ')|lower}, 'display', "Period") }}
{{ dl.make(item, 'subjects', "Subjects", "subject_show") }}
{% endset %}

Expand Down

0 comments on commit edcdbdf

Please sign in to comment.