From 02a69a65a532e9d7233ee7cc23c96afc5a049bd7 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 28 Aug 2024 21:37:38 +0200 Subject: [PATCH] Allow to set input_type on Datetime ingredient editor Since the Datetime ingredient stores date and time values it should be possible to set the input_type to either - time - date - datetime --- app/models/alchemy/ingredients/datetime.rb | 2 +- app/views/alchemy/ingredients/_datetime_editor.html.erb | 3 ++- spec/dummy/config/alchemy/elements.yml | 2 ++ spec/models/alchemy/ingredients/datetime_spec.rb | 6 ++++++ spec/views/alchemy/ingredients/datetime_editor_spec.rb | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/alchemy/ingredients/datetime.rb b/app/models/alchemy/ingredients/datetime.rb index 5bb7794d23..a3953829fa 100644 --- a/app/models/alchemy/ingredients/datetime.rb +++ b/app/models/alchemy/ingredients/datetime.rb @@ -5,7 +5,7 @@ module Ingredients # A datetime value # class Datetime < Alchemy::Ingredient - allow_settings %i[date_format] + allow_settings %i[date_format input_type] def value ActiveRecord::Type::DateTime.new.cast(self[:value]) diff --git a/app/views/alchemy/ingredients/_datetime_editor.html.erb b/app/views/alchemy/ingredients/_datetime_editor.html.erb index 8cf0d5a814..cfdf866855 100644 --- a/app/views/alchemy/ingredients/_datetime_editor.html.erb +++ b/app/views/alchemy/ingredients/_datetime_editor.html.erb @@ -8,7 +8,8 @@ datetime_editor, :value, { name: datetime_editor.form_field_name, id: datetime_editor.form_field_id, - value: datetime_editor.value + value: datetime_editor.value, + type: datetime_editor.settings[:input_type] } ) %>