---
title: "BeforePhoneAreaCodeInitializeEvent"
manual: "LIA Form"
version: "2.2"
permalink: "https://docs.typo3.org/permalink/lia/lia_form:beforephoneareacodeinitializeevent@2.2"
source: "Events/BeforePhoneAreaCodeInitializeEvent.rst"
rendered: "2026-09-29T13:27:41+00:00"
---

# BeforePhoneAreaCodeInitializeEvent {#beforephoneareacodeinitializeevent}

This event is dispatched when the [PhoneAndAreaCode](https://docs.typo3.org/permalink/lia/lia_form:phoneandareacode@2.2)
form element is initialized. It provides the possibility to replace the default
area code list (`EXT:lia_form/Configuration/Data/PhoneAreaCodeList.json`)
with a custom JSON data source.

## Attributes {#attributes}

-   **dataSourcePath**

    -   *Type:* string
    -   *Required:* true

    Path to a JSON file containing the area code list. `EXT:` paths are
    resolved automatically.

## Subscribe this event {#subscribe-this-event}

First create an EventListener class in your Extension. It may look like this.

**EXT:my_extension/Classes/EventListener/BeforePhoneAreaCodeInitializeEventListener.php**

```php
<?php
declare(strict_types=1);

namespace MY\MyExtension\EventListener;

use LIA\LiaForm\Event\BeforePhoneAreaCodeInitializeEvent;

final class BeforePhoneAreaCodeInitializeEventListener {

    /**
    * Set a custom area code list.
    *
    * @param BeforePhoneAreaCodeInitializeEvent $event
    * @return void
    */
    public function __invoke(BeforePhoneAreaCodeInitializeEvent $event): void
    {
        $event->setDataSourcePath('EXT:my_extension/Configuration/Data/MyAreaCodeList.json');
    }
}
```

Now register this EventListener in your `Services.yaml`.

**EXT:my_extension/Configuration/Services.yaml**

```yaml
MY\MyExtension\EventListener\BeforePhoneAreaCodeInitializeEventListener:
  tags:
    - name: event.listener
      identifier: 'my-extension/before-phone-area-code-initialize-event'
      event: LIA\LiaForm\Event\BeforePhoneAreaCodeInitializeEvent
```
