Jump to content

[PS 1.7.6.7] Is there a way to get back the date dropdown like in prestashop 1.6?


Recommended Posts

In the previous version of Prestashop 1.6 the registration  form has datepicker for birthday field with a dropdown list where we can select month, day, year.

Prestashop Version 1.6 [screenshot]

Then in the latest version of Prestashop 1.7.6.7, the registration form for the birthdate field doesn't have datepicker, we need to manually type in date in the birthdate input field.

Prestashop Version 1.7.6.7 [screenshot]

 

In prestashop 1.6 this is the code how the date dropdown appear:

<div class="form-group">
                    <label>
                        {l s='Date of Birth'}
                    </label>
                    <div class="row">
                        <div class="col-xs-4">
                            <select name="days" id="days" class="form-control">
                                <option value="">-</option>
                                {foreach from=$days item=v}
                                    <option value="{$v}" {if ($sl_day == $v)}selected="selected"{/if}>{$v}&nbsp;&nbsp;</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="col-xs-4">
							{*
								{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" class="form-control">
                                <option value="">-</option>
                                {foreach from=$months key=k item=v}
                                    <option value="{$k}" {if ($sl_month == $k)}selected="selected"{/if}>{l s=$v}&nbsp;</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="col-xs-4">
                            <select id="years" name="years" class="form-control">
                                <option value="">-</option>
                                {foreach from=$years item=v}
                                    <option value="{$v}" {if ($sl_year == $v)}selected="selected"{/if}>{$v}&nbsp;&nbsp;</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>

 

In prestashop 1.7, the registration template is located at .. /templates/customer/_partials/customer-form.tpl. In prestashop 1.7, this is the code how the date appear looping the form:

<form action="{block name='customer_form_actionurl'}{$action}{/block}" id="customer-form" class="js-customer-form" method="post">
  <section>
    {block "form_fields"}
      {foreach from=$formFields item="field"}
        {block "form_field"}
          {form_field field=$field}
        {/block}
      {/foreach}
      {$hook_create_account_form nofilter}
    {/block}
  </section>

...

</form>

My question is how to edit this date field before it populate data. Like:


 

{if $field['name'] == 'birthday''} 

// Change birthdate field here to dropdown

{/if}

 

Any idea ?

Edited by arafatx (see edit history)

Share this post


Link to post
Share on other sites

I can see prestashop already has helper form of birthday field:

Find the file ../classes/form/CustomerFormatter.php

in line 196 change the setType('text') to setType('date'):

if ($this->ask_for_birthdate) {
    $format['birthday'] = (new FormField())
        ->setName('birthday')
        ->setType('text')   //change this to date
        ->setLabel(
            $this->translator->trans(
                'Birthdate',
                [],
                'Shop.Forms.Labels'
            )
        )

 

When I use that type birthday I got the populated field like prestashop 1.6 but, it doesn't work when saving. So, I think the birthday type is deprecated helper. Any help ?

Edited by arafatx
mistake (see edit history)

Share this post


Link to post
Share on other sites
  • 1 month later...
On 7/19/2020 at 3:01 AM, arafatx said:

I can see prestashop already has helper form of birthday field:

Find the file ../classes/form/CustomerFormatter.php

in line 196 change the setType('text') to setType('birthday'):


if ($this->ask_for_birthdate) {
    $format['birthday'] = (new FormField())
        ->setName('birthday')
        ->setType('text')   //change this to birthday
        ->setLabel(
            $this->translator->trans(
                'Birthdate',
                [],
                'Shop.Forms.Labels'
            )
        )

 

When I use that type birthday I got the populated field like prestashop 1.6 but, it doesn't work when saving. So, I think the birthday type is deprecated helper. Any help ?

Did you solved??

Share this post


Link to post
Share on other sites
  • 1 month later...
On 8/25/2020 at 1:04 AM, ericksonvornes said:

Did you solved??

 

Edit. Solved it. Actually it works on prestashop 1.7.6.8. Maybe something wrong with the previous prestashop version but now it's working fine when changing to date. Just change what I said. Also I made a mistake about the type. It should be 'date' not 'birthday'

Edited by arafatx (see edit history)

Share this post


Link to post
Share on other sites

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More