X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fweb%2Fclass_WebFormHelper.php;h=79de8131d6a120ef53d4b2eeeb86ce1b22daa3d8;hp=fc14638408cca3c5214e30ed4887e4ba709d54ff;hb=1e2209b0314919177e08f7ec626e9eb2e1f90d70;hpb=11c0ba60cb6c044928f41e93cc98d214b1d8ad7c
diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php
index fc14638..79de813 100644
--- a/inc/classes/main/helper/web/class_WebFormHelper.php
+++ b/inc/classes/main/helper/web/class_WebFormHelper.php
@@ -22,6 +22,11 @@
* along with this program. If not, see .
*/
class WebFormHelper extends BaseHelper {
+ /**
+ * Instance to the class which provides field values
+ */
+ private $valueInstance = null;
+
/**
* Wether the form tag is opened (keep at false or else your forms will
* never work!)
@@ -49,13 +54,13 @@ class WebFormHelper extends BaseHelper {
private $subGroupName = "";
// Class Constants
- const EXCEPTION_FORM_NAME_INVALID = 0xb00;
- const EXCEPTION_CLOSED_FORM = 0xb01;
- const EXCEPTION_OPENED_FORM = 0xb02;
- const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0xb03;
+ const EXCEPTION_FORM_NAME_INVALID = 0x030;
+ const EXCEPTION_CLOSED_FORM = 0x031;
+ const EXCEPTION_OPENED_FORM = 0x032;
+ const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x033;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
@@ -64,7 +69,10 @@ class WebFormHelper extends BaseHelper {
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("HTML-Formularhilfsklasse");
+ $this->setObjectDescription("Helper class for HTML forms");
+
+ // Create unique ID number
+ $this->generateUniqueId();
}
/**
@@ -95,6 +103,24 @@ class WebFormHelper extends BaseHelper {
return $helperInstance;
}
+ /**
+ * Pre-fetches field default values from the given registry key instance into this class
+ *
+ * @param $registryKey
+ * @return void
+ * @throws NullPointerException If an instance from registry is null
+ */
+ public function prefetchFieldValues ($registryKey) {
+ // Get the required instance
+ $this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
+
+ // Is the instance valid?
+ if (is_null($this->valueInstance)) {
+ // Throw an exception
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+ }
+
/**
* Add the form tag or close it an already opened form tag
*
@@ -108,7 +134,7 @@ class WebFormHelper extends BaseHelper {
if (($this->formOpened === false) && ($formName === false)) {
// Thrown an exception
throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
- }
+ } // END - if
// Close the form is default
$formContent = "";
@@ -116,8 +142,9 @@ class WebFormHelper extends BaseHelper {
// Check wether we shall open or close the form
if ($this->formOpened === false) {
// Add HTML code
- $formContent = sprintf("