This repository was archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddressType.php
More file actions
56 lines (49 loc) · 1.66 KB
/
AddressType.php
File metadata and controls
56 lines (49 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Problematic\AuthNetBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class AddressType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$type = $options['address_type'];
$required = 'shipTo' == $type ? true : false;
$builder->add('first_name', 'text', array(
'property_path' => "{$type}FirstName",
));
$builder->add('last_name', 'text', array(
'property_path' => "{$type}LastName",
));
$builder->add('company', 'text', array(
'required' => false,
'property_path' => "{$type}Company",
));
$builder->add('address', 'text', array(
'required' => $required,
'property_path' => "{$type}Address",
));
$builder->add('city', 'text', array(
'required'=>$required,
'property_path' => "{$type}City",
));
$builder->add('state', 'text', array(
'required'=>$required,
'property_path' => "{$type}State",
));
$builder->add('zip', 'text', array(
'required'=>$required,
'property_path' => "{$type}Zip",
));
$builder->add('country', 'text', array(
'required'=>$required,
'property_path' => "{$type}Country",
));
}
public function getDefaultOptions(array $options)
{
return array(
'address_type' => $options['address_type'],
// 'data_class' => 'Problematic\AuthNetBundle\AuthorizeNet\API\ARB\AuthorizeNetSubscription',
);
}
}