You are here

function asset_widget_js in Asset 6

Same name in this branch
  1. 6 modules/asset_content.inc \asset_widget_js()
  2. 6 inc/modules/asset_content.inc \asset_widget_js()
Same name and namespace in other branches
  1. 5 modules/asset_content.inc \asset_widget_js()
1 string reference to 'asset_widget_js'
asset_menu in ./asset.module
Implementation of hook_menu()

File

inc/modules/asset_content.inc, line 339

Code

function asset_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();
  _asset_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('asset_widget_js', $form);
  }
  $form = form_builder('asset_widget_js', $form);
  $output = drupal_render($form);
  print drupal_to_js(array(
    'status' => TRUE,
    'data' => $output,
  ));
  exit;
}