Jump to content

Setting required fields in customer registration


Recommended Posts

you can define field as required in classes/Address.php file

there is an object definition:

public static $definition = array(
		'table' => 'address',
		'primary' => 'id_address',
		'fields' => array(
			'id_customer' => 		array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
			'id_manufacturer' => 	array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
			'id_supplier' => 		array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
			'id_warehouse' => 		array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
			'id_country' => 		array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_state' => 			array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
			'alias' => 				array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
			'company' => 			array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),
			'lastname' => 			array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
			'firstname' => 			array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
			'vat_number' =>	 		array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
			'address1' => 			array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
			'address2' => 			array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
			'postcode' => 			array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
			'city' => 				array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
			'other' => 				array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
			'phone' => 				array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
			'phone_mobile' => 		array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
			'dni' => 				array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
			'deleted' => 			array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
			'date_add' => 			array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
			'date_upd' => 			array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
		),
	);

required fields have got required=> true param, just remove it

  • Like 8
Link to comment
Share on other sites

Littlepants, there is a setting in back office Preferences/Customers where you can make it non-mandatory to provide a phone number.

post-578343-0-38210000-1379803232_thumb.jpg

Set this to No and the red asterisk won't show next to Mobile phone.

 

However if this is set to Yes, it doesn't seem to work as intended - on 1.5.4.1, at least.

The prompt says 'You must register at least one phone number.' and there is also a red asterisk next to Mobile phone.

But it doesn't matter what you enter in these phone number fields - you can populate both, one or neither, and it will be accepted!

Screenshots attached before & after clicking 'Register' where no phone nos. provided.

post-578343-0-65587300-1379798863_thumb.jpgpost-578343-0-59891300-1379798870_thumb.jpg

 

Vekia, I don't think you can just set phone number(s) to 'required'=>true in the code you posted, because it needs to be governed by the back office setting above. There is logic in /controllers/front/AuthController.php which should check for at least one phone number if the back office setting is Yes. However, as demonstrated above, this doesn't seem to work.

 

Incidentally the thread that arncus links to is not directly relevant - it's about the contact form, not the registration form.

 

Link to comment
Share on other sites

  • 1 month later...

Littlepants, there is a setting in back office Preferences/Customers where you can make it non-mandatory to provide a phone number.

attachicon.gifPhones3.JPG

Set this to No and the red asterisk won't show next to Mobile phone.

 

However if this is set to Yes, it doesn't seem to work as intended - on 1.5.4.1, at least.

The prompt says 'You must register at least one phone number.' and there is also a red asterisk next to Mobile phone.

But it doesn't matter what you enter in these phone number fields - you can populate both, one or neither, and it will be accepted!

Screenshots attached before & after clicking 'Register' where no phone nos. provided.

attachicon.gifPhones1.JPGattachicon.gifPhones2.JPG

 

Vekia, I don't think you can just set phone number(s) to 'required'=>true in the code you posted, because it needs to be governed by the back office setting above. There is logic in /controllers/front/AuthController.php which should check for at least one phone number if the back office setting is Yes. However, as demonstrated above, this doesn't seem to work.

Hi,

I've also this problem in PS 1.5.6.0

I think the problem is in /controllers/front/AuthController.php in processSubmitAccount() function

		$error_phone = false;
		if (Configuration::get('PS_ONE_PHONE_AT_LEAST'))
		{
			if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer'))
			{
				if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
					$error_phone = true;
			}
			elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE')) 
					|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')))
					&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
				$error_phone = true;
			elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
					&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
				$error_phone = true;
		}

Is there any fix?

 

Chris

Link to comment
Share on other sites

  • 3 months later...

Hi, I have a query relating to this topic ... I hope!

 

I've purchased the 'Private Shop' module for Prestashop (using PS 1.5.6.2) which allows you to force a login to your shop ... perfect so far.  As per normal account creation process, once the account and password is set up you can log in to the site straight away.  

 

I'd like to make the password field NOT required and comment it out, therefore forcing a manual password input and completion of the account creation process in the backoffice.  I need to assign each user to a group to limit the categories they can see BEFORE they log in and this is the only way I can think of to do that.

 

I've managed to edit authentication.tpl in themes/default to comment out the mandatory password field, but it also needs to be marked as 'false' somewhere else ... and I have no idea where!  I'm getting the error: 

 

There is 1 error

  1. password is required.
     

 

Please help!

 

Thanks, lock-e73   :)

Link to comment
Share on other sites

  • 1 month later...

Hello everybody.

This topic is really helpful for me: in our store we'd like to have the "house number" mandatory because in the address field many of them forget to write in it....

So the carrier has often problems shipping the goods...

 

Do you think we can easily for example edit the "Address 2" field and transform it in a mandatory one?

Note for Prestashop Developers: I think we all would appreciate having a tool to edit, add, delete, change the customers fields :)

 

Thanks!

Link to comment
Share on other sites

  • 2 months later...

Hi,

I've also this problem in PS 1.5.6.0

I think the problem is in /controllers/front/AuthController.php in processSubmitAccount() function

		$error_phone = false;
		if (Configuration::get('PS_ONE_PHONE_AT_LEAST'))
		{
			if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer'))
			{
				if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
					$error_phone = true;
			}
			elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE')) 
					|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')))
					&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
				$error_phone = true;
			elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
					&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
				$error_phone = true;
		}

Is there any fix?

 

Chris

 

Hello to all, 
I have the same problem and I wanted to kindly know how it can be solved. Is there any fix o limitation di Prestashop?
 
Thank you.
Link to comment
Share on other sites

  • 7 months later...

Hey,

 This is my code from address.php and from some odd reason it still asks me for post code as a required field. Somebody any ideas about this ?

 

public static $definition = array(
'table' => 'address',
'primary' => 'id_address',
'fields' => array(
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'vat_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'address1' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
),
);
Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...