function arrange_fields_popup_edit_field in Arrange Fields 7
Same name and namespace in other branches
- 6 arrange_fields.module \arrange_fields_popup_edit_field()
This function, which is meant to be displayed in the popup, will just take the default drupal field's edit form (or the webform 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 348
Code
function arrange_fields_popup_edit_field() {
$type_name = $_REQUEST["type_name"];
$field_name = $_REQUEST["field"];
$GLOBALS["arrange_fields_in_popup"] = TRUE;
if ($type_name != "webform") {
module_load_include('inc', 'field_ui', 'field_ui.admin');
// For reasons which I do not fully understand, sometimes $field_name comes through
// a second time as an array. If this happens, we want to use the original field name.
// That is what this business is about with the $_SESSSION. It's an unpleasant kludge,
// and I would greatly appreciate it if someone could explain what it's all about!
if (!is_array($field_name)) {
$field_name = str_replace("-", "_", $field_name);
$_SESSION["arrange_field_popup_edit_field_name"] = $field_name;
}
else {
$field_name = $_SESSION["arrange_field_popup_edit_field_name"];
$_SESSION["arrange_field_popup_edit_field_name"] = "";
}
$instance = field_info_instance("node", $field_name, $type_name);
// We set this global here, so in our hook_form_alter, we know we need
// to change the redirect of the form_state to go back to our other popup.
$GLOBALS["arrange_fields_editing_field"] = TRUE;
$rtn = drupal_render(drupal_get_form('field_ui_field_edit_form', $instance));
}
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_state to go back to our other popup.
$GLOBALS["arrange_fields_editing_field"] = TRUE;
// Now, attempt to display the form.
$rtn = drupal_render(drupal_get_form('webform_component_edit_form', $node, $component, FALSE));
}
return $rtn;
}