You are here

function arrange_fields_popup_edit_field in Arrange Fields 6

Same name and namespace in other branches
  1. 7 arrange_fields.module \arrange_fields_popup_edit_field()

This function, which is meant to be displayed in the popup, will just take CCK's field_edit_form and display it for us. This is to make it more convienent for the user, so they do not have to go to another page.

Return value

string

1 string reference to 'arrange_fields_popup_edit_field'
arrange_fields_menu in ./arrange_fields.module
Implementation of hook_menu().

File

./arrange_fields.module, line 585

Code

function arrange_fields_popup_edit_field() {
  $type_name = $_REQUEST["type_name"];
  $field_name = $_REQUEST["field"];
  if ($type_name != "webform") {

    // Make sure this CCK include has been loaded.
    module_load_include('inc', 'content', 'includes/content.admin');

    // We set this global here, so in our hook_form_alter, we know we need
    // to change the #redirect of the form to go back to our other popup.
    $GLOBALS["arrange_fields_editing_field"] = TRUE;
    $rtn = drupal_get_form('content_field_edit_form', $type_name, $field_name);
  }
  else {

    // This is a webform!
    // First, get the webform component from the $field_name, which looks like:
    // nid_cid.
    $temp = explode("_", $field_name);
    $nid = $temp[0];
    $cid = $temp[1];
    $component = webform_menu_component_load($cid, $nid, "");

    // Also load the webform as a node.
    $node = node_load($nid);

    // We set this global here, so in our hook_form_alter, we know we need
    // to change the #redirect of the form to go back to our other popup.
    $GLOBALS["arrange_fields_editing_field"] = TRUE;

    // Now, attempt to display the form.
    $rtn = drupal_get_form('webform_component_edit_form', $node, $component, FALSE);
  }
  return $rtn;
}