When I add Office Hours field to a field collection, everything works right except for the "Add more hours" link which just doesn't appear. Same thing happened with 7.x-1.0 version, but there I saw an error message (about non-existing index) and there are issues on that matter in the queue. With dev version, the error doesn't appear, but the issue is still unresolved.

Comments

johnv’s picture

just a guess: does it help to apply the following (and clear caches) ?
#1660480: Property Info callback for Entity API

graker’s picture

Nope, it doesn't.
I guess though, that it's that function that adds "Add more hours" link can't find the office hours field because the field is inside a field collection edit form which is embedded into node edit form. Because when I go to "Add" link (which adds a single field-collection entity without displaying the full node edit form) - "Add office hours" links are in place.

johnv’s picture

That might be the case - embedded forms... PITA (Check out the endles issues of Editablefields)
It does work as a normal field, I hope?
Patches are welcome! :-)

graker’s picture

Yes, it does work as a normal field, both in node edit form and in separate (i.e. not embedded) field-collection edit form. So I guess embedded forms are the issue.
I will try to find a way to fix it but not very soon.

johnv’s picture

Status: Active » Postponed (maintainer needs more info)

What is the status with the latest dev-version?
#1126386: Add more hours link not displayed in Profile2 is fixed. Does is work for field_collection, too?

pedrosp’s picture

Version: 7.x-1.x-dev » 7.x-1.1

I can confirm that last release (nor dev) doesn't work as expected in a field collection. (No add more hours + No granularity)

johnv’s picture

Status: Postponed (maintainer needs more info) » Active
dsrikanth’s picture

StatusFileSize
new1.9 KB

I wrote up a patch that works for me. Adding it here in case anyone wants to have a look at it.
This is for 7.x-1.1

Ignore this attachment - see #9

dsrikanth’s picture

StatusFileSize
new981 bytes

Oops wrong file. Attaching the right one...

johnv’s picture

Status: Active » Needs review
dsrikanth’s picture

Did more testing with patch at #9. Works fine except when there is a field collection inside a field collection. So I am thinking of a generic solution. Something like the below:

function _office_hours_get_field_settings($element, &$form_state) {
  if (isset( $form_state['field'][$element['#field_name']]) ) {
    $field_settings = &$form_state['field'][$element['#field_name']][$element['#language']]['field']['settings'];
  }
  else {
	$arrayiter = new RecursiveArrayIterator($form_state['field']);
	$iteriter = new RecursiveIteratorIterator($arrayiter);
	foreach ($iteriter as $key => $value) {
	$arraycopy = $iteriter->getArrayCopy();
	  if(array_key_exists('addhrs',$arraycopy)){
  		$field_settings = $arraycopy;
 	  }
    }
  }
  return $field_settings;
}

Ideally it should take care of the profile2 issue too. If only I can get the whole [$element['#field_name']][$element['#language']]['field']['settings'] instead of looking for 'addhrs' I would be more confident about this.

Would love to hear your thoughts.

jonhattan’s picture

Patch in #1168126: Default value for every day of the week fixes this indirectly by providing a more consistent widget.

See #1913292: [META] Untangle office_hours for the broad picture.

richardbporter’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Closed (duplicate)

Maybe I'm missing something but is that the right issue? #1913126: Too many hooks

Thanks.

jonhattan’s picture

@rbp I've updated #12 with the correct issue numbers.