Skip to content

Instantly share code, notes, and snippets.

@ABM-Dan
Created April 29, 2016 15:25
Show Gist options
  • Save ABM-Dan/be4f827eb605316593fae6f095d96774 to your computer and use it in GitHub Desktop.
Save ABM-Dan/be4f827eb605316593fae6f095d96774 to your computer and use it in GitHub Desktop.
<?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