Jump to content

[solved] How to make mobile phone or other fields required/not required at registration


Jevgen

Recommended Posts

all was done by this instruction

Some users may need to have the phone number field required for new registrations. This is quite simple and needs you to edit 2 files on your server. Address.php which is located in your classes folder, and also the authentication.tpl file wich is located in your theme folder.

First the Address.php file. Find the the following line of code:

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city');

and change it to:

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city', 'phone');

In the authentication.tpl file find the following code:


{l s='Home phone'}
<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />



and change it to:


{l s='Home phone'}
<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
*



This second section of code adds the astrix to show that the field is required.

You could use the above example to make any of the fields required in your registration process. Just look for the different sections in the authentication.tpl file and add the *.
Link to comment
Share on other sites

and finally for those who wants make mobile phone required at registration and using v1.3.6

1) in folder classes find file Address.php and the following line of code:

protected $fieldsRequired = array(‘id_country’, ‘alias’, ‘lastname’, ‘firstname’, ‘address1’, ‘postcode’, ‘city’);



and change it or add following

protected $fieldsRequired = array(‘id_country’, ‘alias’, ‘lastname’, ‘firstname’, ‘address1’, ‘postcode’, ‘city’, ‘phone_mobile’);



2) in folder theme/your_theme/ find file authentication.tpl and the following code:


{l s='Mobile phone'}
   <input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{/if}" />



and change it to:


{l s='Mobile phone'}
   <input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{/if}" />
*
 



by adding * make field required and adding word required in code below make symbol * red




You can play with other fields to make fields required or not )

Thanks to sbnet for helping

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

authentication.tpl

there are 2 places. Lines 363-366 and lines 206-209


{l s='Zip / Postal Code'}
                       <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}">
*



change to this


{l s='Zip / Postal Code'}
                       <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}">



and in address.php

protected    $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId',
                                       'id_supplier' => 'isNullOrUnsignedId', 'id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId',
                                       'alias' => 'isGenericName', 'company' => 'isGenericName', 'lastname' => 'isName','vat_number' => 'isGenericName',
                                       'firstname' => 'isName', 'address1' => 'isAddress', 'address2' => 'isAddress', 'postcode'=>'isPostCode',
                                       'city' => 'isCityName', 'other' => 'isMessage',
                                       'phone' => 'isPhoneNumber', 'phone_mobile' => 'isPhoneNumber', 'deleted' => 'isBool', 'dni' => 'isDniLite');



remove

'postcode'=>'isPostCode',

Link to comment
Share on other sites

and in theme/your_theme/address.tpl

        

{l s='Zip / Postal Code'}
           <input type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'htmlall':'UTF-8'}{/if}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
*



change to

     

{l s='Zip / Postal Code'}
           <input type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'htmlall':'UTF-8'}{/if}{/if}"/>

Link to comment
Share on other sites

  • 8 months later...
  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...