Author Topic: Add a Custom Field to Tabindex UPDATED 2x  (Read 2027 times)

Offline eldontyrrell

  • Semi-Newbie
  • *
  • Posts: 21
Add a Custom Field to Tabindex UPDATED 2x
« on: December 12, 2014, 02:55:55 AM »


Semi-newbie trying to shake off major rust; apologies in advance but I can't find an answer on the forums.

2.0.9, Default theme, HoneyPot mod and that's it! Not live yet.

I created two custom fields for use in the registration process, and to be displayed alongside users' posts. I renamed "Location" to be "City", then created "State / Province" and populated it for data consistency. Made them "required". All good so far, everything works as desired.

If one tabs through the basic registration form, these fields appear LAST, after the verification, after the SMF info links at the bottom, etc.

I want to add these fields to the tab index so that they become active immediately after the original/"required" registration fields.

I've poked around in register.template.php, and I've located the relevant custom_field passage. This custom_field appears a little differently here than do "passwrd1", "passwrd2", for instance, and I've so far struck out in adding the

tabindex="', $context['tabindex']++, '

in the proper place; I either get template parse errors, OR those two passages appear on the registration page AS TEXT! So I've got to be *really* close...

Now, so far I've looked entirely through pages 30-49 of all "Support" search results for the word "tabindex", and the closest I got was this:

Which led to this:

...but the bug report doesn't nail down the solution. It indicates that this *was* a bit of a hack to accomplish -- at least, as of early 2010 -- but has this progressed any further? I cannot be the only person who has a custom field or two, who wants straight-thru tabbing on the registration page...

Should I post this on another board? Any and all advice appreciated!

hxxp:// (then accept the registration agreement)
« Last Edit: December 17, 2014, 05:27:24 PM by eldontyrrell »

Offline Deaks

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,505
  • Gender: Male
    • SMFReview on Facebook
    • pouvik on GitHub
    • @@smfreview on Twitter
    • SMFReview
Re: Add a Custom Field to Tabindex UPDATED 2x
« Reply #1 on: December 19, 2014, 10:00:36 PM »
if you need help with this still can you show us your code that you moved be good if you can also tell us where you moved the code to to get the error.

Offline eldontyrrell

  • Semi-Newbie
  • *
  • Posts: 21
Re: Add a Custom Field to Tabindex UPDATED 2x
« Reply #2 on: December 24, 2014, 02:44:12 AM »
H.R. Runicness,

Thanks for checking in.

The area in register.template.php, where I've been trying to add the tabindex coding, is within the following lines (which, in my file, are lines 303-313):

// Are there any custom fields?
   if (!empty($context['custom_fields']))
      foreach ($context['custom_fields'] as $field)
         echo '
                     <strong', !empty($field['is_error']) ? ' style="color: red;"' : '', '>', $field['name'], ':</strong>
                     <span class="smalltext">' , $field['desc'] , '</span>
                  <dd> ', $field['input_html'], ' </dd>';

Now, I've never moved or removed any code; all I've done, over the course of several experiments, is to add the

tabindex="', $context['tabindex']++, '

coding in various places within these lines, attempting to mimic where it appears for "standard" fields. Every time but one, I got template parse errors. ONE time, I *didn't* get an error -- but that tab-related code appeared as *text* on the registration page!

In reading through those two other topics I quoted, it looks as if this is not exactly a lay-up (because the "additional" fields come from a different table?), but if it's doable, it would be worthwhile. If you have any ideas let me know, and thanks again for replying.

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,893
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Add a Custom Field to Tabindex UPDATED 2x
« Reply #3 on: December 24, 2014, 01:08:47 PM »
Try changing <dd> to <dd tabindex="', $context['tabindex']++, '">. I'm not entirely sure if that will work since <dd> is a container, but it's worth a shot. If that doesn't work, we'll have to do some string manipulation with input_html (basically find the first ">" or "/>" after "input" and add the tabindex before that).
Michael Eshom
Cincy Space - now open!