1

I am trying to change the input type on an ubercart checkout form using hook_form_alter. I added an extra field using the uc cart extra fields pane module but there is no option to add e-mail - only text - and I need the field I added to validate as an e-mail.

The field in question is:

<input type="text" id="edit-panes-billing-address-billing-ucxf-bill-to-email" name="panes[billing][address][billing_ucxf_bill_to_email]" value="" size="32" maxlength="255" class="form-text required">

The code I am using but with no success is:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'uc-cart-checkout-form') {
    form['panes-billing-address-billing-ucxf-bill-to-email'][LANGUAGE_NONE][0]['type'] = 'email';
  }

Thanks for any assistance!

0

If you want alter a form via an ID check you should be using $form_id == 'uc_cart_checkout_form'. Drupal form generation functions don't use "-" characters like generated CSS id/class attributes.

  • Thanks. Missed that. Unfortunately I now get an error Fatal error: Cannot use string offset as an array in /home/content/g/l/o/.../sites/all/modules/ubercart/uc_store/includes/uc_ajax_attach.inc on line 108. – penone Aug 26 '15 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.