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 Commented Mar 16, 2018 at 13:41
  • @Fabio you’re probably looking for api.drupal.org/api/drupal/… 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 Commented Mar 17, 2018 at 10:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.