You are here

function link_widget_js in Link 5

1 string reference to 'link_widget_js'
link_menu in ./link.module
Implementation of hook_menu().

File

./link.module, line 487
Defines simple link field types.

Code

function link_widget_js($type_name, $field_name) {
  $field = content_fields($field_name, $type_name);
  $type = content_types($type);
  $delta = $_POST[$field_name]['count'];
  $form = array();
  $node_field = array();
  _link_widget_form($form, $field, $node_field, $delta);

  // Assign parents matching the original form.
  foreach (element_children($form) as $key) {
    $form[$key]['#parents'] = array(
      $field_name,
      $delta,
      $key,
    );
  }

  // Add names, ids, and other form properties.
  foreach (module_implements('form_alter') as $module) {
    $function = $module . '_form_alter';
    $function('link_widget_js', $form);
  }
  $form = form_builder('link_widget_js', $form);
  $output = drupal_render($form);
  print drupal_to_js(array(
    'status' => TRUE,
    'data' => $output,
  ));
  exit;
}