I'm working on an Entity where I created a field containing Address informations (like country, city and street).

The default Address Type in Drupal 8 supports only 2 lines for the street information. Is there a way to add an extra line?

closed as too broad by mradcliffe, kiamlaluno Jul 3 at 16:10

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


I found a (partial solution), but new ideas are always well welcomed. I used the field organization as third row and then I rearranged the weights of the fields in this way:

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    if ($form_id == 'specific_add_form' || $form_id == 'specific_edit_form' ) {
        $form['field_address']['widget'][0]['address']['#after_build'][] = 'mymodule_weight_change';


function mymodule_weight_change($element, $form_state) {
    $element['country_code']['#weight'] = -10;
    $element['address_line1']['#weight'] = -7;
    $element['address_line2']['#weight'] = -5;
    $element['organization']['#weight'] = -2;
    $element['postal_code']['#weight'] = 5;
    $element['locality']['#weight'] = 10;

    return $element;

Endly I put the css of the organization label as display: none.

  • another way could be puts a new text field inside your entity and then using javascript to move the field inside tyhe form. – que le Sep 3 '18 at 12:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.