public function selectProfileFormAction() { $request = $this->getRequest(); $form = new \Zend\Form\Form(); $redirect = $this->params()->fromQuery("redirect", ""); //load contact profile forms $arr_forms = $this->getContactsModel()->getContactProfileForm(); //create radio button options foreach ($arr_forms as $key => $form_name) { $arr_element_value_options[$key] = $form_name; } //end foreach //add radio group to form $form->add(array("type" => "radio", "name" => "cpp_form_id", "options" => array("label" => "Please select the form you would like to use:", "value_options" => $arr_element_value_options))); //add remember option radio button $form->add(array('type' => 'checkbox', 'name' => 'remember_form', 'options' => array('label' => 'Remember my option', 'use_hidden_element' => true, 'checked_value' => '1', 'unchecked_value' => '0'))); $form->add(array("name" => "submit", "attributes" => array("value" => "Submit"), "options" => array("ignore" => TRUE))); //check if local storage has been enabled $arr_config = $this->getServiceLocator()->get("config"); if (!isset($arr_config["logged_in_user_settings"])) { $storage_disabled = TRUE; } elseif (isset($arr_config["logged_in_user_settings"]) && $arr_config["logged_in_user_settings"]["storage_enabled"] !== TRUE) { $storage_disabled = TRUE; } //end if if (isset($storage_disabled)) { $form->remove("remember_form"); } //end if //load user session data $objUserStorage = FrontUserSession::getUserLocalStorageObject(); if (is_numeric($objUserStorage->readUserNativePreferences()->cpp_form_id)) { $form->get("cpp_form_id")->setValue($objUserStorage->readUserNativePreferences()->cpp_form_id); } //end if if ($request->isPost()) { //validate form submitted $form->setData($request->getPost()); if ($form->isValid()) { $arr_form_data = $form->getData(); $form_id = $arr_form_data["cpp_form_id"]; if (isset($arr_form_data["remember_form"]) && $arr_form_data["remember_form"] == 1) { //persist user preference if (is_object($objUserStorage)) { $objUserStorage->setUserNativePreferences('cpp_form_id', $form_id); $objUserData->cookie_data->cpp_form_id = $form_id; } //end if } //end if //check if redirect has been specified if ($redirect != "") { //redirect received return $this->redirect()->toUrl($redirect . "?fid={$form_id}"); } //end if //redirect back to the contact edit screen with form id specified $url = $this->url()->fromRoute("front-contacts", array("action" => "create-contact")); //execute redirect $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Location', $url . "?fid={$form_id}"); $response->setStatusCode(302); return $response; } //end if } //end if return array("form" => $form, "redirect" => $redirect); }