Jump to content

Registration - make birthday as a required field


Recommended Posts

  • 4 months later...
  • 2 weeks later...
  • 4 weeks later...

Hmm, I'm trying to do this also.

I cant figure out how to get prestashop to take the 3 different variables of the DOB and make them required.

the name of the input fields for the DOB are 'days' 'months' and 'years'... ive tried putting those into the 'required' script as mentioned on that website (and in this post: http://www.prestashop.com/forums/viewthread/33592/) with no luck...

PS will show an error if you do not complete the respected field (days for days, months for months etc) but once youve completed all three it will show a hack attempt error and says the variable is empty.

I've tried using 'birthday' which is what the mysql databases uses for storing it and the form will then show an error as you have not filled in the 'birthday' field (which obviously doesnt exist on the form as it uses 3 drop downs.

Any help would be greatly appreciated

Thanks

Dan

Link to comment
Share on other sites

  • 3 weeks later...
  • 5 months later...
  • 3 months later...
  • 1 month later...
  • 2 weeks later...
  • 2 weeks later...

anyone??
i got the same problem, i tried following the instructions of making phone number as a required field, and applied it to date of birth, but without success, the asterisk appears next to date of birth(in grey), but the form doesn't recognize the field as required!
I even inserted the date of birth in the require_text class, but without any success..
Does anyone know, how to make it required?
Thank you

Link to comment
Share on other sites

YES!!!
Done it!!
For anyone who needs a hand, in making certain fields "required", or changing the name of any field with custom names, just send me a msg!!

After changing the fields,i fixed it on the Admin side/Database, and it's perfect, so when you go in the users details, all the fields are now displayed correctly!
And i also made the Date of Birth(birthday) a required field!(with the red asterisk) :)

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

Ok....i will post my DOB fields:

That's simple you have to modify these 3 files

Inside your THEME FOLDER change these file

 

1)in authentication.tpl replace your Birthday Class with this:

 

{l s='Birthday'} 

- {foreach from=$days item=day} {$day|escape:'htmlall':'UTF-8'}   {/foreach}  
{* 
{l s='January'} 
{l s='February'} 
{l s='March'} 
{l s='April'} 
{l s='May'} 
{l s='June'} 
{l s='July'} 
{l s='August'} 
{l s='September'} 
{l s='October'} 
{l s='November'} 
{l s='December'} 
*} 
- {foreach from=$months key=k item=month} {l s="$month"}  {/foreach}  

-{foreach from=$years item=year} {$year|escape:'htmlall':'UTF-8'}   {/foreach} 

<sup>*</sup>

 

3)identity.tpl once more replace the DOB CLASS with this:

 

{l s='Birthday'} 

- {foreach from=$days item=v} {$v|escape:'htmlall':'UTF-8'}   {/foreach}  
{* 
{l s='January'} 
{l s='February'} 
{l s='March'} 
{l s='April'} 
{l s='May'} 
{l s='June'} 
{l s='July'} 
{l s='August'} 
{l s='September'} 
{l s='October'} 
{l s='November'} 
{l s='December'} 
*} 
- {foreach from=$months key=k item=v} {l s="$v"}  {/foreach}  
- {foreach from=$years item=v} {$v|escape:'htmlall':'UTF-8'}   {/foreach}  
<sup>*</sup>

 

 

That's it!! Should work...if it gives you problems just let me know…

always really busy, excuse for the answer after many days!

 

 

Link to comment
Share on other sites

Hallo chimera247,

You wrote 3 files: but provides only 2 files:
1, authentication.tpl
2, ?
3, identity.tpl

With this 2 files, it don´t work for me (prestashop 1.4).
It just make asterisk, but not working properly after submit registration form.

Thank you for you hints.

Kind Regards
matkomatko

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

This is so far the best shopping cart experience I've had, until we reached this error. We are using 1.4 and have already finished the site. Once we clicked to require the birthday, it does not allow users to go past this section even when they input a birthday.

 

Will someone please tell me which files to update.

 

Thank you,

Mark

Link to comment
Share on other sites

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

Ok....i will post my DOB fields:

That's simple you have to modify these 3 files

Inside your THEME FOLDER change these file

 

1)in authentication.tpl replace your Birthday Class with this:

 

{l s='Birthday'}

- {foreach from=$days item=day} {$day|escape:'htmlall':'UTF-8'}   {/foreach}  
{*
{l s='January'}
{l s='February'}
{l s='March'}
{l s='April'}
{l s='May'}
{l s='June'}
{l s='July'}
{l s='August'}
{l s='September'}
{l s='October'}
{l s='November'}
{l s='December'}
*}
- {foreach from=$months key=k item=month} {l s="$month"}  {/foreach}  

-{foreach from=$years item=year} {$year|escape:'htmlall':'UTF-8'}   {/foreach}

<sup>*</sup>

 

3)identity.tpl once more replace the DOB CLASS with this:

 

{l s='Birthday'}

- {foreach from=$days item=v} {$v|escape:'htmlall':'UTF-8'}   {/foreach}  
{*
{l s='January'}
{l s='February'}
{l s='March'}
{l s='April'}
{l s='May'}
{l s='June'}
{l s='July'}
{l s='August'}
{l s='September'}
{l s='October'}
{l s='November'}
{l s='December'}
*}
- {foreach from=$months key=k item=v} {l s="$v"}  {/foreach}  
- {foreach from=$years item=v} {$v|escape:'htmlall':'UTF-8'}   {/foreach}  
<sup>*</sup>

 

 

That's it!! Should work...if it gives you problems just let me know…

always really busy, excuse for the answer after many days!

 

Hi, You mention there was three files to update. What would the second one be?

 

Thanks,

Rob.

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 2 weeks later...

Actually, you don't have to modify any code to make the birtday field required. You can do this from the back office of your PrestaShop. Go to Customers tab, then click on the button Set required fields for this section (it's at the bottom of the page). In the table that appears mark the checkbox in front of birthday and click on the Save button. That's it.

 

On the registration form the field won't be marked with a red asterisk, but it will still be required. If the customer doesn't select a birthday (all three drop-down menus), he/she won't be able to register, and a message in red will be displayed that the birthday is required.

 

In case you want to put a red asterisk you have to modify the code of the authentication.tpl file for the particular theme. Find the following string of code:

<p class="select">
  <span>{l s='Date of Birth'}</span>
  <select id="days" name="days">
<option value="">-</option>
{foreach from=$days item=day}
 <option value="{$day|escape:'htmlall':'UTF-8'}" {if ($sl_day == $day)} selected="selected"{/if}>{$day|escape:'htmlall':'UTF-8'}  </option>
{/foreach}
  </select>
  {*
{l s='January'}
{l s='February'}
{l s='March'}
{l s='April'}
{l s='May'}
{l s='June'}
{l s='July'}
{l s='August'}
{l s='September'}
{l s='October'}
{l s='November'}
{l s='December'}
  *}
  <select id="months" name="months">
<option value="">-</option>
{foreach from=$months key=k item=month}
 <option value="{$k|escape:'htmlall':'UTF-8'}" {if ($sl_month == $k)} selected="selected"{/if}>{l s="$month"} </option>
{/foreach}
  </select>
  <select id="years" name="years">
<option value="">-</option>
{foreach from=$years item=year}
 <option value="{$year|escape:'htmlall':'UTF-8'}" {if ($sl_year == $year)} selected="selected"{/if}>{$year|escape:'htmlall':'UTF-8'}  </option>
{/foreach}
  </select>
 </p>

 

It's closer to the end of the file. Don't get confused because there's a similar string of code at the beginning of the file.

 

You can put a red asterisk only after the last drop-down menu (for the year), or you can put an asterisk after each of the three drop down menus.

 

To put a red asterisk after the last drop-down menu insert the following piece of code between the tags </select> and </p> (at the end of the code):

 

<sup style="color:red;">*</sup>

 

To put an asterisk after the other drop-down menus just put the same code after the other two </select> tags.

 

Don't forget that when you make changes to template files you should enable the force compile setting from the back office (Preferences tab>Performance sub-tab), so that you can see the changes when refreshing the frontend. Disable it after you're done.

 

Hope this helps.

  • Like 4
Link to comment
Share on other sites

  • 7 months later...
  • 2 months later...

Following HXD's instructions i realised that in Customers configuration i hadn't the field i was interested to

so I edited PS_ROOT/controllers/admin/AdminCustomersController.php file adding a new parameter in required_fields:

 

from $this->required_fields = array('newsletter','optin');

in $this->required_fields = array('newsletter','optin', 'id_gender');

 

I don't know why but the same editing doesn't work in override/controllers/admin/AdminCustomersController.php file

 

(please let me know if someone knows how override properly this class in override file!)

 

Hope this help!

Edited by RobboR (see edit history)
Link to comment
Share on other sites

  • 9 months later...

Actually, you don't have to modify any code to make the birtday field required. You can do this from the back office of your PrestaShop. Go to Customers tab, then click on the button Set required fields for this section (it's at the bottom of the page). In the table that appears mark the checkbox in front of birthday and click on the Save button. That's it.

 

 

I don't have birthday as an option there, I only have:

- newsletter

-optin

 

How can I add birthday to the list so I can make it a required field?

  • Like 1
Link to comment
Share on other sites

  • 1 month 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...