Form: add required
This commit is contained in:
parent
80023e4f7f
commit
1a485f173e
13 changed files with 26 additions and 15 deletions
|
@ -33,7 +33,7 @@ class RootController < ApplicationController
|
|||
|
||||
def patron
|
||||
@all_champs = TypeDeChamp.type_champs
|
||||
.map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name) }
|
||||
.map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, mandatory: true) }
|
||||
.map { |type_de_champ| Champ.new(type_de_champ: type_de_champ) }
|
||||
.map.with_index do |champ, i|
|
||||
champ.id = i
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
placeholder: champ.libelle,
|
||||
value: champ.value }
|
||||
value: champ.value,
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -1 +1 @@
|
|||
%label{ for: :"champs_#{champ.id}" }>= champ.libelle
|
||||
%label{ for: :"champs_#{champ.id}" }> #{champ.libelle} #{champ.mandatory ? '*' : nil}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%input{ type: 'checkbox',
|
||||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
checked: ('checked' if champ.value == 'on') }
|
||||
checked: ('checked' if champ.value == 'on'),
|
||||
required: champ.mandatory }
|
||||
|
||||
%br
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
placeholder: "JJ/MM/AAAA",
|
||||
id: "champs_#{champ.id}",
|
||||
value: champ.value,
|
||||
type: "date" }
|
||||
type: "date",
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
placeholder: champ.libelle,
|
||||
id: "champs_#{champ.id}",
|
||||
value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first unless champ.value.nil?),
|
||||
type: 'date' }
|
||||
type: 'date',
|
||||
required: champ.mandatory }
|
||||
|
||||
%select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}" }
|
||||
%select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}", required: champ.mandatory }
|
||||
- (0..23).each do |num|
|
||||
- num = "%.2i" %num
|
||||
%option{ value: num, selected: (:selected if champ.same_hour?(num)) }
|
||||
= num
|
||||
h
|
||||
%select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}" }
|
||||
%select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}", required: champ.mandatory }
|
||||
- (0..55).step(5) do |num|
|
||||
- num = "%.2i" %num
|
||||
%option{ value: num, selected: (:selected if champ.same_minute?(num)) }
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
value: champ.value,
|
||||
type: 'number',
|
||||
'autocomplete' => 'off',
|
||||
'data-type' => 'dossier-link' }
|
||||
'data-type' => 'dossier-link',
|
||||
required: champ.mandatory }
|
||||
|
||||
.help-block
|
||||
%p.text-info{ style: show_text_summary ? nil : 'display: none;' }
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
placeholder: champ.libelle,
|
||||
value: champ.value }
|
||||
value: champ.value,
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%input{ type: 'checkbox',
|
||||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
checked: ('checked' if champ.value == 'on') }
|
||||
checked: ('checked' if champ.value == 'on'),
|
||||
required: champ.mandatory }
|
||||
|
||||
%br
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
placeholder: champ.libelle,
|
||||
value: champ.value }
|
||||
value: champ.value,
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
placeholder: champ.libelle,
|
||||
value: champ.value }
|
||||
value: champ.value,
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
name: "champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}",
|
||||
placeholder: champ.libelle,
|
||||
value: champ.value }
|
||||
value: champ.value,
|
||||
required: champ.mandatory }
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
%textarea{ name: "champs['#{champ.id}']",
|
||||
placeholder: champ.description,
|
||||
id: "champs_#{champ.id}",
|
||||
row: '6' }
|
||||
row: '6',
|
||||
required: champ.mandatory }
|
||||
= sanitize(champ.value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue