01.
public
function
subscribeEvents()
02.
{
03.
Backend::
$events
->addEvent(
'shop:onExtendCustomerModel'
,
$this
,
'extend_customer_model'
);
04.
Backend::
$events
->addEvent(
'shop:onExtendCustomerForm'
,
$this
,
'extend_customer_form'
);
05.
Backend::
$events
->addEvent(
'shop:onGetCustomerFieldOptions'
,
$this
,
'get_customer_field_options'
);
06.
}
07.
08.
public
function
extend_customer_model(
$customer
,
$context
)
09.
{
10.
$customer
->define_column(
'x_drop_down'
,
'Some drop-down menu'
);
11.
}
12.
13.
public
function
extend_customer_form(
$customer
,
$context
)
14.
{
15.
$customer
->add_form_field(
'x_drop_down'
)->tab(
'Customer'
)->renderAs(frm_dropdown);
16.
}
17.
18.
public
function
get_customer_field_options(
$field_name
,
$current_key_value
)
19.
{
20.
if
(
$field_name
==
'x_drop_down'
)
21.
{
22.
$options
=
array
(
23.
0 =>
'Option 1'
,
24.
1 =>
'Option 2'
,
25.
2 =>
'Option 3'
26.
);
27.
28.
if
(
$current_key_value
== -1)
29.
return
$options
;
30.
31.
if
(
array_key_exists
(
$current_key_value
,
$options
))
32.
return
$options
[
$current_key_value
];
33.
}
34.
}