function theme_button_field_formatter_default in Button Field 6
Theme function for the 'default' filefield formatter.
Parameters
array $element:
Return value
string
File
- ./
button_field.module, line 150 - Defines a field, widget and formatter for the button field type.
Code
function theme_button_field_formatter_default($element) {
$node = $element['#node'];
$field = content_fields($element['#field_name'], $element['#type_name']);
$name = $field['field_name'] . '-' . $node->nid;
$class = 'button_field' . (isset($field['widget']['additional_class']) ? ' ' . $field['widget']['additional_class'] : '');
// add the javascript and css files
drupal_add_js(drupal_get_path('module', 'button_field') . '/js/button_field.js');
drupal_add_css(drupal_get_path('module', 'button_field') . '/css/button_field.css');
// add the confirmation setting
if (!empty($field['confirmation'])) {
$settings[$name] = array(
'confirmation' => $field['confirmation'],
);
drupal_add_js($settings, 'setting');
}
// determine the widget type
switch ($field['widget']['type']) {
case 'button_field_html':
$return_value = '<button id="' . $name . '" name="' . $name . '" ' . 'class="' . $class . '">' . $field['widget']['text'] . '</button>' . "\n";
break;
case 'button_field_image':
$return_value = '<img src="' . $field['widget']['image_path'] . '" ' . 'alt="' . $field['widget']['alt_text'] . '" ' . 'title="' . $field['widget']['title_text'] . '" ' . 'id="' . $name . '" name="' . $name . '" class="' . $class . '" />' . "\n";
break;
}
// end switch $field['widget']['type']
return $return_value;
}