adding contact form
This commit is contained in:
@ -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
|
||||
|
||||
14
app/views/welcome/_contact_form.erb
Normal file
14
app/views/welcome/_contact_form.erb
Normal 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 %>
|
||||
Reference in New Issue
Block a user