<p></p>
<blockquote>
<p dir="auto">I haven't researched how easy rails makes it to add your own attributes to the field helpers.</p>
</blockquote>
<p dir="auto">I've been looking into this today, and I haven't found any particularly neat way of doing this, other than monkey-patching the TextField initializer to add the option, e.g.</p>
<div class="highlight highlight-source-ruby"><pre><span class="pl-c"># Apply dir=auto to all text fields</span>
<span class="pl-c"># Also includes fields subclassed from TextField, like PasswordField, EmailField etc</span>
<span class="pl-k">module</span> <span class="pl-v">ActionView</span>
  <span class="pl-k">module</span> <span class="pl-v">Helpers</span>
    <span class="pl-k">module</span> <span class="pl-v">Tags</span>
      <span class="pl-k">class</span> <span class="pl-v">TextField</span>
        <span class="pl-k">def</span> <span class="pl-en">initialize</span><span class="pl-kos">(</span><span class="pl-s1">object_name</span><span class="pl-kos">,</span> <span class="pl-s1">method_name</span><span class="pl-kos">,</span> <span class="pl-s1">template_object</span><span class="pl-kos">,</span> <span class="pl-s1">options</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span>
          <span class="pl-smi">super</span><span class="pl-kos">(</span><span class="pl-s1">object_name</span><span class="pl-kos">,</span> <span class="pl-s1">method_name</span><span class="pl-kos">,</span> <span class="pl-s1">template_object</span><span class="pl-kos">,</span> <span class="pl-s1">options</span><span class="pl-kos">.</span><span class="pl-en">reverse_merge</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-pds">:dir</span> <span class="pl-c1">=></span> <span class="pl-pds">:auto</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
        <span class="pl-k">end</span>
      <span class="pl-k">end</span>
    <span class="pl-k">end</span>
  <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">Reading the source code for <a href="https://github.com/rails/rails/blob/7-0-stable/actionview/lib/action_view/helpers/tags/text_field.rb">TextField</a> and <a href="https://github.com/rails/rails/blob/7-0-stable/actionview/lib/action_view/helpers/tags/base.rb">Base</a> doesn't give me any hints that there are configurable defaults for the options hashes, only that they are expected to be passed in by the caller.</p>
<p dir="auto">I guess a non-monkey-patching approach would be to use our own FormBuilder that subclasses bootstrap_form's <a href="https://github.com/bootstrap-ruby/bootstrap_form/blob/main/lib/bootstrap_form/form_builder.rb">FormBuilder</a>, and add the default html attributes at that stage. I haven't explored that approach yet to see if there's any gotchas there.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3430#issuecomment-1041941272">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLHPGB23BR3WPWN36TU3PQW3ANCNFSM5MKZAGKQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLN77JNUSSMSYYVULU3U3PQW3A5CNFSM5MKZAGK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHYNMGGA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/3430/c1041941272</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/3430#issuecomment-1041941272",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3430#issuecomment-1041941272",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>