Custom field of format type date default value

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102106

How to set default value "Today" for custom field of format type date?

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 6 months ago #102124

Hi,

I think that you'll need some code customization to do it, can you give me more information about your custom field through some screenshot then I'll maybe be able to help you.

Thanks :).

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102126

Mohamed Thelji wrote: Hi,

I think that you'll need some code customization to do it, can you give me more information about your custom field through some screenshot then I'll maybe be able to help you.

Thanks :).


I'm om Hikashop demo site B)

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #102370

There is no option to set the default value as today. But if you click on the date picker icon, it will have today selected by default.
To also have it filled in the input box, you would have to add the code:
<?php $this->order->delivery_date = hikashop_getDate(time(),'%d-%B-%Y'); ?>
at the beginning of the file "fields" of the view "checkout" via the menu Display->Views for that custom field.
Note that it won't work on our demo website since we do not authorize the modification of files on it for security reasons.

The following user(s) said Thank You: alikon1

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102458

nicolas wrote: There is no option to set the default value as today. But if you click on the date picker icon, it will have today selected by default.
To also have it filled in the input box, you would have to add the code:
<?php $this->order->delivery_date = hikashop_getDate(time(),'%d-%B-%Y'); ?>
at the beginning of the file "fields" of the view "checkout" via the menu Display->Views for that custom field.
Note that it won't work on our demo website since we do not authorize the modification of files on it for security reasons.


But '%d-%B-%Y' show error: DateTime::__construct() [datetime.--construct]: Failed to parse time string (06-May-2013) at position 0 (0): Unexpected character. So use '%d-%m-%Y'

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #102471

Yes, that was a quick example of code. The format of the date actually depends on what you put in the format field of the custom field.

Please Log in or Create an account to join the conversation.

  • Posts: 177
  • Thank you received: 5
11 years 6 months ago #102475

nicolas wrote: Yes, that was a quick example of code. The format of the date actually depends on what you put in the format field of the custom field.


Tried to change format field to %d-%B-%Y, but with enabled option "Only future dates" got error "Please select a date in the future", when select date in the future :blink:

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #102514

Hi,

There is a little mistake in the algorithm which change the month in text to his number.
Please update the file "administrator/com_hikashop/classes/field.php" and replace the line

$conversion .= 'for(var j=0;j<12;++j){if(Calendar._MN[j].substr(0,elems['.$mP.'].length).toLowerCase()==elems['.$mP.'].toLowerCase()){elems['.$mP.']=j;break;}};
By
$conversion .= 'for(var j=0;j<12;++j){if(Calendar._MN[j].substr(0,elems['.$mP.'].length).toLowerCase()==elems['.$mP.'].toLowerCase()){elems['.$mP.']=(j+1);break;}};
It will fix your problem (and this fix will be include in the next HikaShop release).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: alikon1

Please Log in or Create an account to join the conversation.

Time to create page: 0.087 seconds
Powered by Kunena Forum