function fontawesome_iconpicker_field_widget_form in Font Awesome Iconpicker 7
Implements hook_field_widget_form().
File
- ./
fontawesome_iconpicker.module, line 102 - Integrates fontawesome-iconpicker plugin with Drupal.
Code
function fontawesome_iconpicker_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'fontawesome_iconpicker_textfield':
$element += array(
'#type' => 'fontawesome_iconpicker_textfield',
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
'#size' => $instance['widget']['settings']['size'],
'#maxlength' => $field['settings']['max_length'],
'#attributes' => array(
'class' => array(
'text-full',
),
),
);
return array(
'value' => $element,
);
case 'fontawesome_iconpicker_icon_field':
$element['bundle'] = array(
'#type' => 'value',
'#value' => 'fontawesome',
);
$element['icon'] = array(
'#type' => 'fontawesome_iconpicker_textfield',
'#title' => $element['#title'],
'#description' => $element['#description'],
'#value_callback' => 'fontawesome_iconpicker_icon_field_icon_value_callback',
'#default_value' => isset($items[$delta]['icon']) ? FONTAWESOME_ICONPICKER_ICON_PREFIX . $items[$delta]['icon'] : NULL,
'#attributes' => array(
'class' => array(
'text-full',
),
),
);
break;
}
return $element;
}