function soft_length_limit_field_attach_form in Soft Length Limit 7
Implements hook_field_attach_form().
File
- ./
soft_length_limit.module, line 161 - Soft Length Limit module
Code
function soft_length_limit_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
$entity_types = _soft_length_limit_types('entity_types');
if (!isset($entity_types[$entity_type])) {
return;
}
$fields = field_info_instances($entity_type, $form['#bundle']);
$elements = array();
foreach ($fields as $key => $value) {
if (isset($value['widget']['settings']['soft_length_limit']) && $value['widget']['settings']['soft_length_limit'] > 0) {
$elements[$key] = $value;
}
}
if (count($elements) || isset($form['title'])) {
soft_length_limit_set_attr($form, $elements);
// Adds the javascript and CSS files as form attachments, in case the init
// hook does not add them due to the context or settings.
$form['#attached']['js'][] = drupal_get_path('module', 'soft_length_limit') . '/jquery.textchange.min.js';
$form['#attached']['js'][] = drupal_get_path('module', 'soft_length_limit') . '/soft_length_limit.js';
$form['#attached']['css'][] = drupal_get_path('module', 'soft_length_limit') . '/soft_length_limit.css';
}
}