function Page_Main() { global $objForm, $Language, $gsFormError, $t_vins; // Process form if post back if ($objForm->GetValue("a_addopt") != "") { $t_vins->CurrentAction = $objForm->GetValue("a_addopt"); // Get form action $this->LoadFormValues(); // Load form values // Validate form if (!$this->ValidateForm()) { $t_vins->CurrentAction = "I"; // Form error, reset action $this->setFailureMessage($gsFormError); } } else { // Not post back $t_vins->CurrentAction = "I"; // Display blank record $this->LoadDefaultValues(); // Load default values } // Perform action based on action code switch ($t_vins->CurrentAction) { case "I": // Blank record, no action required break; case "A": // Add new record $t_vins->SendEmail = TRUE; // Send email on add success if ($this->AddRow()) { // Add successful $XMLDoc = new cXMLDocument("utf-8"); $XMLDoc->AddRoot("root"); $XMLDoc->AddRow("result"); $XMLDoc->AddField("x_id", strval($t_vins->id->DbValue)); $XMLDoc->AddField("x_nom", strval($t_vins->nom->FormValue)); $XMLDoc->AddField("x_producteur", strval($t_vins->producteur->FormValue)); $XMLDoc->AddField("x_appelation", strval($t_vins->appelation->FormValue)); $XMLDoc->AddField("x_cepage", strval($t_vins->cepage->FormValue)); $XMLDoc->AddField("x_cuvee", strval($t_vins->cuvee->FormValue)); $XMLDoc->AddField("x_categorie", strval($t_vins->categorie->FormValue)); $XMLDoc->AddField("x_region_du_monde", strval($t_vins->region_du_monde->FormValue)); $XMLDoc->AddField("x_pays", strval($t_vins->pays->FormValue)); $XMLDoc->AddField("x_regions", strval($t_vins->region->FormValue)); $XMLDoc->AddField("x_sous_region", strval($t_vins->sous_region->FormValue)); header("Content-Type: text/xml"); echo $XMLDoc->XML(); $this->Page_Terminate(); exit; } else { $this->RestoreFormValues(); // Add failed, restore form values } } // Render row $t_vins->RowType = EW_ROWTYPE_ADD; // Render add type $t_vins->ResetAttrs(); $this->RenderRow(); }