1

I need to rename the field of Middle Name/Initial in my registration form: https://www.khouryhome.com/customer/account/create/ to Father's name and want to make it mandatory and not optional like it is now in the system-->customer configuration. Thanks in advance for the help.

<div class="field name-middlename">
        <label for="<?php echo $this->getFieldId('middlename')?>" class="required"><?php echo $this->getStoreLabel('middlename'); ?> FATHER NAME <em>*</em></label>
        <div class="input-box">
            <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->escapeHtml($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> />
        </div>
    </div>

this is for the first name:

<div class="field name-firstname">
        <label for="<?php echo $this->getFieldId('firstname')?>" class="required"><em>*</em><?php echo $this->getStoreLabel('firstname') ?></label>
        <div class="input-box">
            <input type="text" id="<?php echo $this->getFieldId('firstname')?>" name="<?php echo $this->getFieldName('firstname')?>" value="<?php echo $this->escapeHtml($this->getObject()->getFirstname()) ?>" title="<?php echo $this->getStoreLabel('firstname') ?>" maxlength="255" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('firstname') ?>" <?php echo $this->getFieldParams() ?> />
        </div>
    </div>

1 Answer 1

0

Copy the following file:

app/design/frontend/base/default/template/customer/widget/name.phtml

to your theme like below:

app/design/frontend/[your_package]/[your_theme]/customer/widget/name.phtml

And change the text.

For make it required from database:

Goto eav_attribute table and find the middlename attribute code and change the field is_required to 1.

Also from here you can change the Text of Middle name to Father's name as well.

Change the following in name.phtml:

<div class="field name-middlename">
    <label for="<?php echo $this->getFieldId('middlename')?>" class="required">FATHER NAME <em>*</em></label>
    <div class="input-box">
        <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->escapeHtml($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text required-entry<?php echo $this->helper('customer/address')->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> />
    </div>
</div>
22
  • dear for the required its well received, as for the renaming im still lost in this label where i should change the name? <label for="<?php echo $this->getFieldId('middlename')?>"<?php echo $isMiddlenameRequired ? ' class="required"' : '' ?>><?php echo $isMiddlenameRequired ? '<em>*</em>' : '' ?><?php echo $this->getStoreLabel('middlename') ?></label>
    – Marcos
    Aug 13, 2018 at 14:51
  • as for Goto eav_attribute table and find the middlename attribute code and change the field is_required to 1.--> i dont have attributes with first name, middle name or last name. if its at level database, where exactly are you pointing? you mean SQL or PHP MY ADMIN? up their i should change it??
    – Marcos
    Aug 13, 2018 at 14:52
  • You can find the label in the same table. I mean magento database from phpmyadmin. Aug 13, 2018 at 15:21
  • dear i prefer not to change anything from the database of SQL or PHP MY ADMIN, cant we just rename it in the registration file in this line of code: <label for="<?php echo $this->getFieldId('middlename')?>"<?php echo $isMiddlenameRequired ? ' class="required"' : '' ?>><?php echo $isMiddlenameRequired ? '<em>*</em>' : '' ?><?php echo $this->getStoreLabel('middlename') ?></label>
    – Marcos
    Aug 14, 2018 at 6:49
  • Yes you can change it from there but if somewhere the same thing happens then you need to change that manually. Database change will effect for every places. Aug 14, 2018 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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