Created
April 29, 2016 15:25
-
-
Save ABM-Dan/be4f827eb605316593fae6f095d96774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // *Snip* | |
| class CreditCardType extends AbstractType | |
| { | |
| public function buildForm(FormBuilderInterface $builder, array $options) | |
| { | |
| /** | |
| * @var Entity\CreditCard $data | |
| */ | |
| $data = $builder->getData(); | |
| // *Snip* | |
| $fullProfileAddress = false; | |
| $user = $data->getUser(); | |
| /** @noinspection IsEmptyFunctionUsageInspection */ | |
| if ($user instanceof User | |
| && !empty($user->getAddress()) | |
| && !empty($user->getCity()) | |
| && !empty($user->getState()) | |
| //&& !empty($user->getZip()) Probably we can allow an empty zip code? | |
| && !empty($user->getCountry()) | |
| ){ | |
| $fullProfileAddress = true; | |
| } | |
| if ($fullProfileAddress) { | |
| $builder->add('billing_as_profile', CheckboxType::class, [ | |
| 'label' => 'Use billing address from my profile', | |
| 'attr' => ['autocomplete' => 'off'], | |
| 'data' => true, | |
| 'required' => false, | |
| ]); | |
| } | |
| // *Snip* | |
| } | |
| // *Snip* | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment