[SOLVED] Custom Field Format for Date-Field

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 3 months ago #58757

Hello there

I have an issue and I don't know, if it's a bug or maybe a feature.

What I want todo is to define 2 additional (custom) fields on the user table.

Date of Birth (user_birthdate): shall have the format dd.mm.yyyy (e.g. 25.08.1970), allowing only dates in the past, also allowing an empty field for "undefined"
Validity until (user_valid_until): shall have the format dd.mm.yyyy (e.g. 25.08.1970), allowing only dates in the future, also allowing an empty field for "undefined"

So far so good. I defined the two fields and entered the format: %d.%m.%Y
This results in an error like:

Warning: preg_split() [function.preg-split]: Compilation failed: POSIX collating elements are not supported at offset 0 in C:\xampp\htdocs\hikashop\administrator\components\com_hikashop\classes\field.php on line 1280

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\hikashop\administrator\components\com_hikashop\classes\field.php on line 1280

Then I googled a little bit and found, that maybe the format shall be %d"."%m"."%Y but when I enter the format like this and press "Save", the whole mask changes and then I do not understand what to setup. The system accepts then "dates" like: asdfasdf and the calendar button in the customer/user mask do not work anymore.

Therefore, I think it's maybe a bug? Or I'm doing something completely wrong.
Please check the attached PDF for further information and screenshots of the behavior.

How can I define my desired date-format without getting such trouble?
Thanks for any help!
Best regards
Mike

Attachments:
Last edit: 12 years 2 months ago by mike.

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 3 months ago #58771

Hmm, I think I just found the solution:

The format must be: %d\.%m\.%Y

But the validation: "Only past dates" / "Only future dates" do not work with that setting. Maybe there are some issues/bugs. But I hope, a developer can that decide, what goes wrong.

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 3 months ago #58777

Just found out something new:

If the field Format of a Date Custom Field is %d\.%m\.%Y and the "Allow" field is set to "Only future dates", the "validation" will show an error if you enter a date e.g. 25.10.2013

"Please select a date in the future".

I think, here is something buggy. Please move the thread to the "BUG"-Section.

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 3 months ago #58788

Dots are indeed not supported at separator with the current code.

Can you try to change the line:
$seps = preg_replace('#%.#iU','',$field->field_options);

to:
$seps =str_replace(array('%','.'),array('','\.'),$field->field_options);

in the file administrator/components/com_hikashop/classes/field.php ?

That should hopefully make it work with dots.

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 3 months ago #58898

Hello Nicolas
Thank you for your reply. I tried it out, but it seems not to work. If I add such a string add the line of code as you described, then no date (regardless how it's specified) is accepted and always a formatting error is returned in the User-Admin UI.

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 3 months ago #58936

Hi,

Ok, try instead to try to change the line:
$seps = preg_replace('#%.#iU','',$field->field_options);

to:
$seps = preg_replace('#[a-z0-9%]#iU','',$field->field_options);
$seps = str_replace(array('.'),array('\.'),$seps);

at the same place.

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 3 months ago #58979

:( I can't get it work :dry:

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 3 months ago #59041

It's working fine for us with that modification.
Can you give more information ? Did you get a javascript error ? Can you check your browser's javascript error console ?
Still the same message ? Can you double check that you did the modification properly ?

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

  • Posts: 108
  • Thank you received: 4
  • Hikashop Business
12 years 2 months ago #64321

Sorry for writing back to this issue so late!

I updated yesterday my Shop to the actual version 1.6.0!
I saw, that the validation of dates with "." works very well :woohoo: ! THANK YOU VERY MUCH (makes the life easier)!

Just for other users who want todo the same: For a (birth)date like 25.08.1978, the custom field format must be specified like this: %d.%m.%Y and the "Allow" Field must be set to "Only past dates" and there you go for a birthdate field on the customer mask in your backend!

Very nice!
Thanks :)

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

Time to create page: 0.051 seconds
Powered by Kunena Forum