1

I need to add a checkbox to make billing information same as shipping information in drupal 8. So i want remove required fields into billing address and set this information programmatically after submit the form.

But is very hard to remove required fields from billing information into checkout panes. I also hack the Drupal\address\Element\Address.php at line 202 to set the #required attribute to FALSE but when i submit the form, i have always the message "... field is required."

Why the attribute #required => FALSE doesn't work? Why is so hard to modify this field? Why is not there a template for this field?

thanks

1 Answer 1

1

You have to use hook_form_alter to changing form elements options. This field is required because very often payments modules need this data to prepare correct post variables.

3
  • You can't. Into form alter you have only an array with element #type => commerce_profile_select and not the single fields of address field
    – Fabio Riva
    Commented Mar 16, 2018 at 13:41
  • @Fabio you’re probably looking for api.drupal.org/api/drupal/…
    – Clive
    Commented Mar 16, 2018 at 19:15
  • I try but the result is the same. i think that i will create custom shipping and billing pane and will save informations programmatically. thanks
    – Fabio Riva
    Commented Mar 17, 2018 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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