Module: ActionView::Helpers::FormTagHelper
- Defined in:
- lib/prime/rails/form_tag_helper.rb
Instance Method Summary collapse
- #p_button_tag(content_or_options = nil, options = nil, &block) ⇒ Object
- #p_check_box_tag(name, value = "1", checked = false, options = {}) ⇒ Object
- #p_password_field_tag(name = "password", value = nil, options = {}) ⇒ Object
- #p_select_tag(name, option_tags = nil, options = {}) ⇒ Object
- #p_text_area_tag(name, content = nil, options = {}) ⇒ Object
- #p_text_field_tag(name, value = nil, options = {}) ⇒ Object
Instance Method Details
#p_button_tag(content_or_options = nil, options = nil, &block) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/prime/rails/form_tag_helper.rb', line 96 def ( = nil, = nil, &block) = if block_given? && .is_a?(Hash) ||= {} = .stringify_keys if disable_with = .delete("disable_with") = ":disable_with option is deprecated and will be removed from Rails 4.1. " \ "Use 'data: { disable_with: \'Text\' }' instead." ActiveSupport::Deprecation.warn ["data-disable-with"] = disable_with end if confirm = .delete("confirm") = ":confirm option is deprecated and will be removed from Rails 4.1. " \ "Use 'data: { confirm: \'Text\' }' instead'." ActiveSupport::Deprecation.warn ["data-confirm"] = confirm end .reverse_merge! 'name' => 'button', 'type' => 'submit' clientid = sanitize_to_id(["id"]) if ['ajax'] ['onclick'] = '' if !.has_key?('onclick') ['onclick'] += "PrimeFaces.ab({source: '#{clientid}'});return false;" end output = content_tag :button, || 'Button', , &block = .has_key?("widgetVar") ? ["widgetVar"] : "widget_"+clientid = = .merge(:id => clientid ) = .to_json script = '$(function() {' script += "PrimeFaces.cw('Button','#{}',#{})" script += '});' output += p_javascript_tag(script, "id" => clientid+"_s") end |
#p_check_box_tag(name, value = "1", checked = false, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/prime/rails/form_tag_helper.rb', line 46 def p_check_box_tag(name, value = "1", checked = false, = {}) = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(.stringify_keys) ["checked"] = "checked" if checked output = tag :input, clientid = sanitize_to_id(name) = .has_key?("widgetVar") ? ["widgetVar"] : "widget_"+clientid = = .merge(:id => clientid ) = .to_json script = '$(function() {' script += "PrimeFaces.cw('CheckBox','#{}',#{})" script += '});' output += p_javascript_tag(script, "id" => clientid+"_s") end |
#p_password_field_tag(name = "password", value = nil, options = {}) ⇒ Object
65 66 67 |
# File 'lib/prime/rails/form_tag_helper.rb', line 65 def p_password_field_tag(name = "password", value = nil, = {}) p_text_field_tag(name, value, .update("type" => "password")) end |
#p_select_tag(name, option_tags = nil, options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/prime/rails/form_tag_helper.rb', line 69 def p_select_tag(name, = nil, = {}) ||= "" html_name = ([:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name if .delete(:include_blank) = content_tag(:option, '', :value => '').safe_concat() end if prompt = .delete(:prompt) = content_tag(:option, prompt, :value => '').safe_concat() end output = content_tag :select, , { "name" => html_name, "id" => sanitize_to_id(name) }.update(.stringify_keys) clientid = sanitize_to_id(name) = .has_key?("widgetVar") ? ["widgetVar"] : "widget_"+clientid = = .merge(:id => clientid ) = .to_json script = '$(function() {' script += "PrimeFaces.cw('Dropdown','#{}',#{})" script += '});' output += p_javascript_tag(script, "id" => clientid+"_s") end |
#p_text_area_tag(name, content = nil, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/prime/rails/form_tag_helper.rb', line 22 def p_text_area_tag(name, content = nil, = {}) = .stringify_keys clientid = sanitize_to_id(name) = .has_key?("widgetVar") ? ["widgetVar"] : "widget_"+clientid if size = .delete("size") ["cols"], ["rows"] = size.split("x") if size.respond_to?(:split) end escape = .delete("escape") { true } content = ERB::Util.html_escape(content) if escape output = content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update() = = .merge(:id => clientid ) = .to_json script = '$(function() {' script += "PrimeFaces.cw('InputTextarea','#{}',#{})" script += '});' output += p_javascript_tag(script, "id" => clientid+"_s") end |
#p_text_field_tag(name, value = nil, options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/prime/rails/form_tag_helper.rb', line 2 def p_text_field_tag(name, value = nil, = {}) = .stringify_keys clientid = sanitize_to_id(name) = .has_key?("widgetVar") ? ["widgetVar"] : "widget_"+clientid output = tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(.stringify_keys) = "InputText" = "Password" if ['type'] == 'password' = = .merge(:id => clientid ) = .to_json script = '$(function() {' script += "PrimeFaces.cw('#{}','#{}',#{})" script += '});' output += p_javascript_tag(script, "id" => clientid+"_s") end |