adding contact form

This commit is contained in:
Karl-Heinz Wild
2025-12-10 19:12:09 +01:00
parent 40df42bfd9
commit 2a0325196f
3 changed files with 32 additions and 1 deletions

View File

@ -5,4 +5,20 @@ class WelcomeController < ApplicationController
def pages
render params[:page]
end
def contact
@name = params.fetch(:name, "kein Name angegeben")
puts @name
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.update("contact",
partial: "welcome/contact_form",
locals: {
name: @name
}
)
end
end
end
end

View File

@ -0,0 +1,14 @@
<%= turbo_frame_tag :contact do %>
<div class="mt-5">
<%#= debug DateTime.now %>
<%= form_with url: contact_url do |form| %>
<% if @name %>
<p class="my-5">Sie haben <%= @name %> eingegeben.
<% end %>
<%= form.text_field :name %>
<%= form.button "Daten senden" %>
<% end %>
</div>
<% end %>