Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Tab Ordering on a PHP created Form


3 Posts   1712 Views


Community Member, 97 Posts

27 January 2011 at 11:01pm

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 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" />')



Forum Moderator, 1805 Posts

27 January 2011 at 11:49pm

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.


Community Member, 97 Posts

28 January 2011 at 1:20am

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

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


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

thanks to