Jump to:

1975 Posts in 1305 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Tab Ordering on a PHP created Form

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1411 Views
  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Tab Ordering on a PHP created Form Link to this post

    how can i set the tab order on a form that is creating in a php file.

    I can't tab through the credit card field ...it keeps jumping on to cvv2Number.

    Here's my code

    function getPaymentFormFields() {
          $mt = array('mm','01','02','03','04','05','06','07','08','09','10','11','12');
          // lil loop so $yr will always contain this year +/- 5 years;
          $yr = array(0=>'yyyy');
          for ($x = (date('Y') - 5); $x <= date('Y') + 5; $x++) {
             $yr[$x] = $x;
          }
          $issu = array('01','02','03','04','05');         
          $cardvalue = array('0','1','9','S','8');
          $cardname = array(
                      'Visa'      => 'Visa',
                      'MasterCard'=> 'MasterCard',
                      'Switch'   => 'Switch',
                      'Solo'      => 'Solo',
                      'Other'      => 'Other'
                   );

          return new FieldSet(

          new DropdownField('creditCardType','Card Type', $cardname, $cardvalue),
          new CreditCardField("CreditCardNumber", "Credit Card Number:"),
        new DropdownField('expDateMonth','Expiration Date', $mt, $mt),
          new DropdownField('expDateYear','', $yr, $yr),
          new LiteralField("extrafields", '<div id="extrafields" style="display:none;">'),
          new DropdownField('startDateMonth','Start Date', $mt, $mt),
          new DropdownField('startDateYear','', $yr, $yr),
          new DropdownField('cardIssue','Issue No', $issu, $issu),
          new LiteralField("extrafields", '</div>'),
    new NumericField("cvv2Number", "Card Verification Number:", "", 3),
    new LiteralField("cvv2img", '<img src="/themes/winderworld/images/cvv2.gif" id="cvvimage" alt="cvv2" />')

          );
       }

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Tab Ordering on a PHP created Form Link to this post

    The tab order will be in the order that the fields are rendered I believe, you could create your FormField items and ->setTabIndex() manually on each one.

  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Re: Tab Ordering on a PHP created Form Link to this post

    Thanks, i saw that in docs but not sure how and where i'd use it exactly

    new DropdownField('creditCardType','Card Type', $cardname, $cardvalue),

    creditCardType->setTabIndex(99)

    I usedjQuery in the end, which saved altering php, but a little example of setTabIndex in use would help.

    thanks to
    http://greatwebguy.com/programming/dom/setting-your-tabindex-on-your-html-forms-automatically-with-jquery/

    1411 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.