It might be useful to include a field formatter that outputs the icon itself for the text field widget. Currently, I think the only formatting option is the text string for the icon's CSS class.

So instead of seeing this: fa-users

You'd see this: <i class="fa fa-users fa-1x" aria-hidden="true"></i>

Comments

hey_germano created an issue. See original summary.

hey_germano’s picture

Status: Active » Needs review
StatusFileSize
new2.29 KB

Patch attached. This adds the formatter, as well as the option to select an icon size.

BigEd’s picture

Hi great module, unfortunately its a bit of a requirement to have the output in the html so I was pleased to see that you guys have created a patch the module.

I tried to test this and I can see the field formatter but I still get no class output in the html so it's missing something.

  • D34dMan committed eabae4b on 7.x-1.x authored by hey_germano
    Issue #2716947 by hey_germano, BigEd: Add a field formatter for...
d34dman’s picture

Status: Needs review » Fixed

Thanks for the contribution

BigEd’s picture

Ok figured this out, it does not work at the moment as the output for fontawesome_iconpicker_field_formatter_view is only giving a blank result in the output.

/**
 * Implements hook_field_formatter_view().
 */
function fontawesome_iconpicker_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {
    case 'fontawesome_iconpicker_icon':
      $size = $display['settings']['size'];
      foreach ($items as $item) {
        $element[] = '<i class="fa '. $item['value'] . ' fa-'. $size . '" aria-hidden="true"></i>';
      }
      break;
  }

  return $element;
}

However you can use the Icon field in the Icon API as this is not a text field it seems to work if you apply it and use the icon picker with it.

You have two choices we either locate the bug in the above code or make this module dependent on the Icon API.

d34dman’s picture

Status: Fixed » Needs work

Oh sorry i mixed up issues... this was not supposed to be committed :( Sorry.

d34dman’s picture

hi @hey_germano, this issue is assigned to you, but i would like to see this fixed asap. Are you still working on this? If not, please unassign so that other's can look into it.

d34dman’s picture

Btw, fontawesome_iconpicker already supports integration with icon_api, so is this still necessary?

hey_germano’s picture

StatusFileSize
new1.08 KB

Apologies for the delay here. This patch should fix the bug with the formatter.

d34dman’s picture

Status: Needs work » Needs review
eric115’s picture

Status: Needs review » Reviewed & tested by the community

+1 for patch in #10, fixes this issue.

  • D34dMan committed 49c01fb on 7.x-1.x authored by hey_germano
    Issue #2716947 by hey_germano, BigEd: Add a field formatter for...
d34dman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the contribution and testing. Committed to 7.x-1.x-dev branch

Status: Fixed » Closed (fixed)

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