/**
* Implements hook_field_widget_form()
*/
function talent_pages_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$show_more = array();
switch ($instance['widget']['type']) {
case 'credit_role':
// Define items that are initially displayed
$priority_options = array(
t('Writer'),
t('Artist'),
t('Cover'),
);
// Prepare the list of options.
$options = _options_get_options($field, $instance, $properties, $entity_type, $entity);
$original_options = $options;
// Get the default values
$default_values = _options_storage_to_form($items, $options, $value_key, $properties);
$outer_options = array();
$value_key = key($field['columns']);
// remove top X options
foreach ($priority_options as $option) {
$key = array_search($option, $options);
if ($key !== FALSE) {
$outer_options[$key] = $option;
unset($options[$key]);
}
}
$combined_options = array(
'outer' => $outer_options,
'inner' => $options,
);
//build widget form element -- This is where we're tying in our validation and theme methods
$element += array(
'#type' => 'checkboxes',
'#options' => $original_options,
'#combined_options' => $combined_options,
'#default_value' => $default_values,
'#value_key' => $value_key,
'#attributes' => array('class' => array('credit-role')),
'#theme' => 'talent_pages_credit_role_checkboxes',
'#element_validate' => array('talent_pages_credit_role_checkboxes_validate', ),
);
// add attached styling and js
$element['#attached']['css'] = array(drupal_get_path('module', 'talent_pages') . '/talent_pages.css');
$element['#attached']['js'] = array(drupal_get_path('module', 'talent_pages') . '/talent_pages.js');
break;
}
return $element;
}