Browse Source

required fields in forms

master
Dom SP 3 years ago
parent
commit
af02b2fe75
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      app/views/form.htm

+ 6
- 4
app/views/form.htm View File

<form action="{{ @target }}" method="post"> <form action="{{ @target }}" method="post">
<repeat group="{{ @fields }}" key="{{ @name }}" value="{{ @info }}"> <repeat group="{{ @fields }}" key="{{ @name }}" value="{{ @info }}">
<check if="{{ @info.type == 'text' }}">
<check if="{{ in_array(@info.type,['text','email']) }}">
<true> <true>
<input <input
name="{{ @name }}" name="{{ @name }}"
id="{{ @name }}" id="{{ @name }}"
type="text"
type="{{ @info.type }}"
size="{{ @info.length }}" size="{{ @info.length }}"
value="{{ @info.value }}" />
value="{{ @info.value }}"
{{ @info.required ? 'required' : '' }} />
<label for="{{ @name }}">{{ @info.description }}</label><br> <label for="{{ @name }}">{{ @info.description }}</label><br>
</true> </true>
</check> </check>
type="radio" type="radio"
id="{{ sprintf('%s-%s',@name,@key) }}" id="{{ sprintf('%s-%s',@name,@key) }}"
name="{{ sprintf('%s',@name) }}" name="{{ sprintf('%s',@name) }}"
value="true"
value="{{ @val }}"
{{ @info.required ? 'required' : '' }}
{{ is_array(@info.checked) ? in_array(@key,@info.checked) ? 'checked' : '' : !strcmp(@key,@info.checked) ? 'checked' : '' }} /> {{ is_array(@info.checked) ? in_array(@key,@info.checked) ? 'checked' : '' : !strcmp(@key,@info.checked) ? 'checked' : '' }} />
<label for="{{ sprintf('%s-%s',@name,@key) }}"> <label for="{{ sprintf('%s-%s',@name,@key) }}">
{{ @val }}</label> {{ @val }}</label>

Loading…
Cancel
Save