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 1d4524250b..a318475f04 100644 --- a/app/views/alchemy/ingredients/_datetime_editor.html.erb +++ b/app/views/alchemy/ingredients/_datetime_editor.html.erb @@ -7,7 +7,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] } ) %> <% end %> diff --git a/spec/dummy/config/alchemy/elements.yml b/spec/dummy/config/alchemy/elements.yml index e17fc01680..a8936248ac 100644 --- a/spec/dummy/config/alchemy/elements.yml +++ b/spec/dummy/config/alchemy/elements.yml @@ -123,6 +123,8 @@ - role: datetime type: Datetime hint: true + settings: + input_type: datetime - role: file type: File hint: true diff --git a/spec/models/alchemy/ingredients/datetime_spec.rb b/spec/models/alchemy/ingredients/datetime_spec.rb index 4df72dd9c5..aba0893d49 100644 --- a/spec/models/alchemy/ingredients/datetime_spec.rb +++ b/spec/models/alchemy/ingredients/datetime_spec.rb @@ -16,6 +16,12 @@ ) end + describe ".allowed_settings" do + it "sets allowed_settings" do + expect(described_class.allowed_settings).to eq([:date_format, :input_type]) + end + end + describe "value" do subject { datetime_ingredient.value } diff --git a/spec/views/alchemy/ingredients/datetime_editor_spec.rb b/spec/views/alchemy/ingredients/datetime_editor_spec.rb index 5bec45db8f..fe0ffe7abd 100644 --- a/spec/views/alchemy/ingredients/datetime_editor_spec.rb +++ b/spec/views/alchemy/ingredients/datetime_editor_spec.rb @@ -17,6 +17,6 @@ it "renders a datepicker" do render element_editor - expect(rendered).to have_css('input[type="text"][data-datepicker-type="date"].date') + expect(rendered).to have_css('input[type="text"][data-datepicker-type="datetime"].datetime') end end