1

Strangely my popup calendar is localized, showing day names and so on in correct language, but not the date in the textfield neither in the description, which remained Y-m-d formatted.

enter image description here.

This should be french format : d-m-Y . And I also need to change default value from today to next week. So, as per this answer :

(For date popup) Branch 7.x-2 : Implementing hook_date_popup_process_alter() you could remove the description...

I tried these diff snippets :

function vts_commerce_date_popup_process_alter(&$element, &$form_state, $context) {
  $element['#date_format'] = 'd-m-Y';//no effect
  $element['date']['#date_format'] = 'd-m-Y';//no effect
  $element['#default_value'] = date('d-m-Y', strtotime('+1 week'));//no effect
  unset($element['date']['#description']);//works but I need to display it with correct date format instead 
  dsm($element);
  return $element;
}

From which snippets 4 changes the form element. Instead, snippets 1, 2, 3 changed $element into dsm() returned values, but change nothing in the form. So my questions are:

  • How to display date into the textfield and in its description in french format ? how to change the default value that will be shown on page loading ?
  • What is the difference here between $element['#foo'] and $element['date']['#foo'] ?

Many thanks for your replies.

1 Answer 1

1

Well I'm a bit ashamed :( No need to do such complicated things. In the edit field page, there are some advanced settings and values I had never paid attention to :

  • Date entry options : control the order and format of the options users see.

Date entry options

  • Default date : Relative default value (Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See strtotime for more details.

Default date : Relative default value

1
  • Anyway, I would be happy to know an=bout the 2nd question... What is the difference in hook_date_popup_process_alter() between $element['#foo'] and $element['date']['#foo'] ?
    – Kojo
    Jun 18, 2014 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.