I've added a date field from the date module that I'd like to add metadata for, so I've set the type to "date" in hook_entity_property_info().

When setting this property, it validates the value with this code in entity_property_verify_data_type() :

return is_numeric($data) && strpos($data, '.') === FALSE"

The problem is then the date field is expecting a string compatible with MySQL's datetime column format, so I either fail one validation or the other.

Is there a different data type I should be declaring that I've missed, or does the validation need improving?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Active » Closed (works as designed)

The date module is integrated with the entity api, so fitting metadata is generated automatically.

Pedro Lozano’s picture

Issue summary: View changes
Status: Closed (works as designed) » Needs review
FileSize
500 bytes

I don't know if it is related but this issue sounds like it is.

I've using this patch successfully for some sorting with dates in custom tables that I wasn't able to do.

Status: Needs review » Needs work

The last submitted patch, 2: 1104286-entity-date.patch, failed testing.

Pedro Lozano’s picture

Status: Needs work » Needs review
FileSize
352 bytes

Fixed patch.

  • Commit 4d2cc6f on 7.x-1.x by fago:
    Issue #1104286: Support generating database schema for date properties.
    
fago’s picture

Title: Entity API's date data type doesn't seem to be compatible with date fields. » Support generating database schema for date properties.
Category: Support request » Task
Status: Needs review » Fixed

Indeed - date is missing here. I think it should be stored as integer though as by default this is a timestamp. Also 'datetime' is no valid data type, so I restricted it to that.

-> Committed a fix to let it be integer.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.