Hello,
this is my first question in this forums. I already read many documentation about drupal 7, however I'm still getting many troubles developing my module. I hope you can help me.
My question is. I have a content type with a field that is a date, and many other fields of course. I want to introduce the date in the validation or submit function because I don't want the user to edit this value. The problem is so simple, I know how to set values like integers or text using "form_set_value" in the validation function, but I don't know how to set a date!!
My code:
function fablab_order_validation(&$form, &$form_state) {
// I set the state of this order to 0
form_set_value($form['fablab_field_order_state'], 0, $form_state); # 0 = placed
// I want to set the "limit date" to today + 5 days. But I'm trying hardcoding a date
form_set_value($form['fablab_field_limit_date'], '03/26/2016 - 15:00', $form_state);
}
First "form_set_value" works. But I get an error with the second: "the date is not valid format". Could somebody tell me the way to do it?
Thanks!
Comments
If I recall correctly, you
If I recall correctly, you need to set an array with the keys year, month and day:
Thanks for your anwer, but it
Thanks for your anwer, but it doesn't work...
the error I'm getting is:
I paste here the definition of the field. Maybe somebody knows what I'm doing wrong
and here the instance
I repeat my question again. How can I set a date value using form_set_value in the validation function?
Thanks!
I finally changed the field
I finally changed the field to be an integer and I update it with UNIX time value... So, my problem is "solved".
Anyway, if somebody knows the format of dates to update them via form_set_values an answer will be welcome.
Regards