You are here

function weight_field_attach_form in Weight 7.2

Implements hook_field_attach_form().

File

./weight.module, line 407

Code

function weight_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  if ($entity_type == 'node') {
    $settings = _weight_get_settings($entity->type);
    if (isset($settings['enabled']) && $settings['enabled'] && !$settings['menu_weight']) {
      $form['weight'] = array(
        '#type' => 'fieldset',
        '#title' => t('Weight'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#group' => 'additional_settings',
        '#access' => user_access('assign node weight'),
        '#attached' => array(
          'js' => array(
            drupal_get_path('module', 'weight') . '/weight.js',
          ),
        ),
      );
      $form['weight']['weight_weight'] = array(
        '#type' => 'select',
        '#title' => t('Weight'),
        '#options' => _weight_get_options($settings['range']),
        '#default_value' => isset($entity->weight_weight) ? $entity->weight_weight : $settings['default'],
      );
    }
  }
}