function fp_render_form

7.x render.inc fp_render_form($callback, $form_type = "")
6.x render.inc fp_render_form($callback, $form_type = "")
4.x forms.inc fp_render_form($callback, $form_type = "")
5.x render.inc fp_render_form($callback, $form_type = "")

Render the form array from the callback to the screen, and set the form to save itself in our default submit handler. Valid form_types are: "system_settings" => values automatically saved to variables table. "normal" or BLANK => values are forwarded to $callback_submit() function, if it exists.

5 calls to fp_render_form()
advise_display_view in modules/advise/advise.module
This is the page which actually displays the "view" for the user to see their advising session, or for an advisor to advise them.
comments_display_main in modules/comments/comments.module
This displays the primary Comments tab, where we see past comments and can enter a new one (with the right permissions).
hook_render_block in modules/blocks/blocks.module
Example of hook_render_block
system_display_login_page in modules/system/system.module
Display the "login" page. This is the default page displayed to the user, at /login, if they have not logged in yet.
system_render_block in modules/system/system.module

File

includes/render.inc, line 238

Code

function fp_render_form($callback, $form_type = "") {
  global $current_student_id, $user;
  $rtn = "";

  // Were there extra params after callback and form_type?  Wrap them up
  // and send them along to fp_get_form
  $params = array();
  if (func_num_args() > 2) {
    // Remove first 2 arguments, so all we have left is what the user added to it.
    $params = func_get_args();
    array_shift($params);
    array_shift($params);
  }

  $form = fp_get_form($callback, $params);

  // Base64 enc the params, so we can easily handle if there are quotation marks, line breaks, etc.
  $form_params = base64_encode(serialize($params));

  // Figure out the current page's title and display it.
  $path = fp_no_html_xss($_GET ["q"]); // Sanitize _GET valuses.

  $default_path = $path;
  $default_query = "";
  // Figure out the "default_query" from $_GET
  $new_query = array();
  foreach ($_GET as $key => $val) {

    // Sanitize since it is coming from _GET.  
    $key = fp_no_html_xss($key);
    $val = fp_no_html_xss($val);


    if ($key != "q") {
      $new_query [] = "$key=$val";
    }
  }
  if (count($new_query)) {
    $default_query = join("&", $new_query);
  }

  $page_title = $GLOBALS ["fp_current_menu_router_item"]["title"];
  if (isset($GLOBALS ["fp_set_title"])) {
    $page_title = $GLOBALS ["fp_set_title"];
  }

  if ($page_title != "") {
    //$rtn .= "<h2 class='title'>" . $page_title . "</h2>";
    fp_show_title(TRUE);
  }

  //fpm($GLOBALS["fp_current_menu_router_item"]);
  $form_path = $GLOBALS ["fp_current_menu_router_item"]["path"];

  // Are there any files required to get to the submit handler for this form?
  $form_include = "";
  // Set the form_include to the current page's "file" requirement, if any.
  if (is_array($GLOBALS ["fp_current_menu_router_item"])) {
    if (isset($GLOBALS ["fp_current_menu_router_item"]["file"])) {
      $form_include = $GLOBALS ["fp_current_menu_router_item"]["file"];
    }
  }
  if (@$form ["#form_include"]) {
    $form_include = $form ["#form_include"];
  }

  $extra_form_class = "";
  if ($form_type == "system_settings") {
    $extra_form_class = "fp-system-form";
  }

  $form_token = md5($callback . fp_token());

  // Set up our form's attributes.
  $attributes = @$form ["#attributes"];
  if (!is_array($attributes)) {
    $attributes = array();
  }

  if (!isset($attributes ["class"])) {
    $attributes ["class"] = "";
  }
  $attributes ["class"] .= " $extra_form_class fp-form fp-form-$callback ";
  // Convert the attributes array into a string.
  $new_attr = "";
  foreach ($attributes as $key => $val) {
    $new_attr .= " $key='$val' ";
  }
  $attributes = $new_attr;

  // Did the user specify a submit method (like GET or POST)?  POST is default.
  $submit_method = (@$form ["#submit_method"] == "") ? "POST" : $form ["#submit_method"];

  $rtn .= "<form action='" . fp_url("system-handle-form-submit", "", TRUE) . "' method='$submit_method' id='fp-form-$callback' name='fp_form_name_$callback' $attributes>";

  $rtn .= "<input type='hidden' name='callback' value='$callback'>";
  $rtn .= "<input type='hidden' name='form_token' value='$form_token'>";
  $rtn .= "<input type='hidden' name='form_type' value='$form_type'>";
  $rtn .= "<input type='hidden' name='form_path' value='$form_path'>";
  $rtn .= "<input type='hidden' name='form_params' value='$form_params'>";
  $rtn .= "<input type='hidden' name='form_include' value='$form_include'>";
  $rtn .= "<input type='hidden' name='default_redirect_path' value='$default_path'>";
  $rtn .= "<input type='hidden' name='default_redirect_query' value='$default_query'>";
  $rtn .= "<input type='hidden' name='current_student_id' value='$current_student_id'>";

  $use_callback = "";
  if (form_has_errors()) {
    // We will only pull previous POST's values if there are errors on the form.
    $use_callback = $callback;
  }


  $rtn .= fp_render_array($form, $use_callback);


  // If this is a system settings form, go ahead and display the save button.
  if ($form_type == "system_settings") {
    $rtn .= "<div class='buttons'>";
    //$rtn .= fp_render_button("Save settings", "\$(\"#sysform\").submit()");
    $rtn .= "<input type='submit' name='submit_button' value='" . t("Save settings") . "'>";
    $rtn .= "</div>";
  }


  $rtn .= "</form>";


  // Clear any existing form errors and values
  unset($_SESSION ["fp_form_errors"]);
  clear_session_form_values($callback);

  return $rtn;

}