Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: eldontyrrell on December 12, 2014, 02:55:55 AM

Title: Add a Custom Field to Tabindex UPDATED 2x
Post by: eldontyrrell on December 12, 2014, 02:55:55 AM
(UPDATED 2x)

Gang,

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:

     http://www.simplemachines.org/community/index.php?topic=337600.msg2270425#msg2270425

Which led to this:

     http://dev.simplemachines.org/mantis/view.php?id=3782

...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://www.puerto-vallarta-ripoff.com/pv_ripoff_folder/forums/index.php?action=register (then accept the registration agreement)
Title: Re: Add a Custom Field to Tabindex UPDATED 2x
Post by: Deaks 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.
Title: Re: Add a Custom Field to Tabindex UPDATED 2x
Post by: eldontyrrell 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):

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


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.
Title: Re: Add a Custom Field to Tabindex UPDATED 2x
Post by: Oldiesmann 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).