I have address the 2nd street text box(2nd street line), but when I enter the address on both text boxes.
code for 1st street line
<input type="text" name="street[]"
value="<?= $block->escapeHtmlAttr($block->getStreetLine(1)) ?>"
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?>"
id="street_1"
class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>"/>
code for other street lines
<div class="nested">
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 1, $_n = $this->helper(\Magento\Customer\Helper\Address::class)->getStreetLines(); $_i < $_n; $_i++): ?>
<div class="field additional">
<label class="label" for="street_<?= /* @noEscape */ $_i + 1 ?>">
<span><?= $block->escapeHtml(__('Street Address %1', $_i + 1)) ?></span>
</label>
<div class="control">
<input type="text" name="street[]"
value="<?= $block->escapeHtmlAttr($block->getStreetLine($_i + 1)) ?>"
title="<?= $block->escapeHtmlAttr(__('Street Address %1', $_i + 1)) ?>"
id="street_<?= /* @noEscape */ $_i + 1 ?>"
class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>">
</div>
</div>
<?php endfor; ?>
</div>
I checked the address from street_1 and street_2 are saved as one in street column
of the table customer_address_entity
separated by a newline "\n"
When I print this <?= $block->escapeHtmlAttr($block->getStreetLine(1)) ?>
in php echo but gives me empty result, but somwehow the street address is set in the textbox.
I need to get the street address and split it into for street_1
and street_2
I don't see any value set to value attribute in chrome inspect as per code. Then how value is getting populated. And how can I get that value and split to get the first line of street and 2nd line of the street address?