Class: Trance::Form
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Trance::Form
- Defined in:
- lib/trance/form.rb
Instance Method Summary collapse
- #date_picker(method, options = {}, html_options = {}) ⇒ Object
- #datetime_picker(method, options = {}, html_options = {}) ⇒ Object
-
#upload_field(method, options = {}, html_options = {}) ⇒ Object
Field for file upload with JavaScript.
Instance Method Details
#date_picker(method, options = {}, html_options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/trance/form.rb', line 27 def date_picker(method, = {}, = {}) dp_id = 'dp-' + _get_id(method) value = _get_value(method) value_string = value ? value.strftime('%d/%m/%Y') : '' hidden = hidden_field(method) @template.raw(<<-EOL #{hidden} <input id="#{dp_id}" size="10" type="text" value="#{value_string}"/> <script type="text/javascript"> $(document).ready(function() { $('##{dp_id}').datepicker({ altField: '#{dp_id}', altFormat: 'yy-mm-dd' }); }); </script> EOL ) end |
#datetime_picker(method, options = {}, html_options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trance/form.rb', line 5 def datetime_picker(method, = {}, = {}) dtp_id = 'dtp-' + _get_id(method) value = _get_value(method) value_string = value ? value.strftime('%d/%m/%Y %H:%M') : '' hidden = hidden_field(method) @template.raw(<<-EOL #{hidden} <input id="#{dtp_id}" size="16" type="text" value="#{value_string}"/> <script type="text/javascript"> $(document).ready(function() { $('##{dtp_id}').datetimepicker({ timeFormat: 'hh:mm', hourGrid: 4, minuteGrid: 10, onSelect: grupus.fn.dtpSelect }); }); </script> EOL ) end |
#upload_field(method, options = {}, html_options = {}) ⇒ Object
Field for file upload with JavaScript
48 49 50 51 52 53 54 |
# File 'lib/trance/form.rb', line 48 def upload_field(method, = {}, = {}) @template.raw <<-EOF <label>Imagens</label><br/> <input id="upload-field-0" type="button" value="Adicionar arquivo" data-name="#{@object_name}[#{method}]" /> <div class="clearfix" id="upload-queue-0"></div> EOF end |