Skip to content

Commit ddd4d60

Browse files
committed
1 parent 7e6ee88 commit ddd4d60

File tree

8 files changed

+50
-10
lines changed

8 files changed

+50
-10
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
44
ruby '2.7.1'
55

66
gem 'jquery-rails', '~> 4.3'
7-
gem 'client_side_validations', '~> 16.2.0'
7+
gem 'client_side_validations', github: 'MichalRemis/client_side_validations', branch: 'SupportDateTimeSelects' # '~> 16.2.0'
88
gem 'client_side_validations-simple_form', '~> 10.1.0'
99

1010
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

Gemfile.lock

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
GIT
2+
remote: https://github.com/MichalRemis/client_side_validations.git
3+
revision: 5fa9a94829831b8714a5458431f54d992f597d9b
4+
branch: SupportDateTimeSelects
5+
specs:
6+
client_side_validations (16.2.0)
7+
js_regex (~> 3.1)
8+
rails (>= 5.0.0.1, < 6.1)
9+
110
GEM
211
remote: https://rubygems.org/
312
specs:
@@ -62,10 +71,6 @@ GEM
6271
builder (3.2.4)
6372
byebug (11.1.3)
6473
character_set (1.4.0)
65-
client_side_validations (16.2.0)
66-
jquery-rails (~> 4.3)
67-
js_regex (~> 3.1)
68-
rails (>= 5.0.0.1, < 6.1)
6974
client_side_validations-simple_form (10.1.0)
7075
client_side_validations (>= 15.0, < 17.0)
7176
simple_form (~> 5.0)
@@ -200,7 +205,7 @@ PLATFORMS
200205
DEPENDENCIES
201206
bootsnap (>= 1.4.2)
202207
byebug
203-
client_side_validations (~> 16.2.0)
208+
client_side_validations!
204209
client_side_validations-simple_form (~> 10.1.0)
205210
jbuilder (~> 2.7)
206211
jquery-rails (~> 4.3)

app/assets/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
//= require jquery
22
//= require rails.validations
3+
//= require rails.validations.simple_form

app/models/box.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
class Box < ApplicationRecord
2+
validates :name, presence: true
3+
validates :description, presence: true
4+
validates :a_date, presence: true
5+
validates :a_datetime, presence: true
6+
validates :a_time, presence: true
27
end

app/views/boxes/_form.html.erb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<%= form_with(model: box, local: true) do |form| %>
1+
<h4>Test CSV 784</h4>
2+
<%= form_with(model: box, local: true, validate: true) do |form| %>
23
<% if box.errors.any? %>
34
<div id="error_explanation">
45
<h2><%= pluralize(box.errors.count, "error") %> prohibited this box from being saved:</h2>
@@ -23,17 +24,17 @@
2324

2425
<div class="field">
2526
<%= form.label :a_date %>
26-
<%= form.date_select :a_date %>
27+
<%= form.date_select :a_date, prompt: true %>
2728
</div>
2829

2930
<div class="field">
3031
<%= form.label :a_datetime %>
31-
<%= form.datetime_select :a_datetime %>
32+
<%= form.datetime_select :a_datetime, prompt: true %>
3233
</div>
3334

3435
<div class="field">
3536
<%= form.label :a_time %>
36-
<%= form.time_select :a_time %>
37+
<%= form.time_select :a_time, prompt: true %>
3738
</div>
3839

3940
<div class="actions">

app/views/boxes/_simple_form.html.erb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<h4>Test CSV 784</h4>
2+
<%= simple_form_for(box, validate: true) do |form| %>
3+
<% if box.errors.any? %>
4+
<div id="error_explanation">
5+
<h2><%= pluralize(box.errors.count, "error") %> prohibited this box from being saved:</h2>
6+
7+
<ul>
8+
<% box.errors.full_messages.each do |message| %>
9+
<li><%= message %></li>
10+
<% end %>
11+
</ul>
12+
</div>
13+
<% end %>
14+
15+
<%= form.input :name %>
16+
<%= form.input :description %>
17+
<%= form.input :a_date, prompt: true %>
18+
<%= form.input :a_datetime, prompt: true %>
19+
<%= form.input :a_time, prompt: true %>
20+
21+
<div class="actions">
22+
<%= form.submit %>
23+
</div>
24+
<% end %>

app/views/boxes/new.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<h1>New Box</h1>
22

3+
<!-- <%= render 'simple_form', box: @box %> -->
4+
35
<%= render 'form', box: @box %>
46

57
<%= link_to 'Back', boxes_path %>

app/views/pages/home.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
<h1>Client Side Validations Playground</h1>
2+
3+
<%= link_to 'CSV 784', new_box_path %>

0 commit comments

Comments
 (0)