The custom token support is needless clutter in the UI and also in code, and only hardens maintenance, no need for that.

Comments

keithm’s picture

Status: Active » Needs review
StatusFileSize
new1.84 KB

I'm not aware of any custom UI token support in the 7.x-2.x branch. I removed the lazy entity loading function.

sun’s picture

With "custom support", I mainly meant the huge chunk of code in viewfield_field_widget_form().

The Token API is in D7 core. Only the Token UI is in contrib. So, regardless of whether Token module is installed, D7 style tokens will work.

If Token module is installed, then we can additionally output the token UI help. However, we should not output it for every single field widget in the form.

keithm’s picture

Token help is currently only attached to the first viewfield on a form.

The following code provides some help if the token module isn't enabled:

  else {
    $entity_info = entity_get_info($element['#entity_type']);
    $entity_id_token = '[' . $element['#entity_type'] . ':' . $entity_info['entity keys']['id'] . ']';
    $element['vargs']['#description'] .=
    '<br />' . t('You may use %entity-id-token for the id of the current entity.', array('%entity-id-token' => $entity_id_token))
    . '<br />' . t('Enable the %token module to get a complete listing of replacement tokens.', array('%token' => t('Token')));
  }

If we don't include something along these lines, I think we should enforce a hard dependency on the token module, or prepare for a large number of support requests :) In the end, a hard dependency might be the best solution anyway, in which case we could lose this whole else{}.

keithm’s picture

Rerolled and cleaned up some more. This issue should be closed before working on #1230248: Store vargs serialized instead of custom delimited string.

keithm’s picture

Reworded and cleaned up the token description language.

keithm’s picture

Status: Needs review » Fixed

Pushed this to get rid of too many dependent patches. We'll clean up later as necessary. Commit: http://drupalcode.org/project/viewfield.git/commit/35031ad.

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