The following requirement comes from #2553935: Add a comment field to each time slot (D7):

I have a requirement to add a new field in each time slot to show users which services has been offered on that respective shift.

The code from that D7 issue is implemented her for D8

Comments

johnv created an issue. See original summary.

  • johnv committed 01f25b4 on 8.x-1.x
    Issue #2860038 by johnv, ripz0r: Add a comment field to each time slot (...
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.0-alpha1
Status: Active » Fixed

Committed with attribution.
Thanks ripz0r, nice feature, which was on the bucket list a long time.

micahw156’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
Status: Fixed » Needs work

I just updated one of our Drupal 8 sites to office_hours-8.x-1.0-alpha1 and ran the database updates. office_hours_update_8003() did not properly extend the schema of my office hours fields.

This site has four fields with office_hours type:

  1. field_winter_hours
  2. field_spring_hours
  3. field_summer_hours
  4. field_fall_hours

Update 8003 specifically looks for tables matching %office_hours% and adds a field field_office_hours_comment to any found. This would presumably find the node__field_office_hours and node_revision__field_office_hours tables for a field named office_hours but does not work in this case.

Those table names don't match the field names above, and the schema field names should be field_winter_hours_comment, etc, as well.

The corresponding D7 update from #2553935: Add a comment field to each time slot (D7) uses a different process to identify and update tables, and does not appear to have this problem.

I don't have time to work up a proper patch right now, but I think the replacement update could do something like this to find the tables and field names that need updating:

  $fields = \Drupal::entityManager()->getFieldMapByFieldType("office_hours");
  foreach ($fields as $entity_type => $entity_fields) {
    foreach (array_keys[$entity_fields] as $field) {
      // use $entity_type and $field to identify tables for updating.
      // add a database column called $field . "_comment"
    }
  }

  • johnv committed d699309 on 8.x-1.x
    Issue #2860038: Add a comment field to each time slot (D8)
    
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.0-alpha1
Status: Needs work » Fixed

This should to the trick. I'll provide a new version.
Thanks for the fast response.

Status: Fixed » Closed (fixed)

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