1

Given a hash of properties for a text_field to be made in HAML:

entry = {class: "form-control", disabled: true, id: :foobar}

How can I do this:

%dd!= f.send(:text_field, entry[:id], class: entry[:class], disabled: entry[:disabled])

But flexible? (So don't need placeholders, just a hash). Have looked at simple form docs and action view form helper docs and found input_html, but that's not working in this manner.

The f.send is obligatory, as :text_field can be anything. Would prefer not to use eval

Community
  • 1
  • 1
xxjjnn
  • 14,591
  • 19
  • 61
  • 94

1 Answers1

2

text_field takes:

text_field(attribute_name, input_html_options)

Does

f.text_field(entry[:id], entry)

not work?

joni
  • 5,402
  • 1
  • 27
  • 40
  • It certainly works for text_field =) But if I do `f.send(:text_field, entry[:id], entry.except(:id))` it doesn't work. If I don't find a way around this, I will use a `case` statement for all the types of inputs – xxjjnn Jun 05 '14 at 19:32
  • `f.send(:text_field, entry[:id], entry)` ? – joni Jun 05 '14 at 19:34
  • Nah that doesn't work. There aren't that many helpers so I don't mind typing them out – xxjjnn Jun 05 '14 at 19:52