We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    According to the docs,


    &regRequired

    WebLoginPE allows you to specify which inputs in your form are required for registration.

    The regRequired parameter is a comma separated list of form field "name" attributes that the user MUST fill out.

    If the form is submitted and one of your required fields is blank, WebLoginPE will display a message notifying the user of which required fields they left blank.

    But I tried a very basic call;

    // Webloginpe call in a "(blank)" template
    [!WebLoginPE? &type=`register` &regType=`verify`!]
    


    And launched the webpage. If I press "submit", it should tell me about the fields I’ve missed, or I’ve left blank.

    But for some reason it keeps reporting;


    "You have left some required form fields blank."

    How do I make WebloginPE pick up my required fields and list them?

    Many thanks

      • 30228
      • 8 Posts
      I’m also having this problem. I set up the notification chunk but it doesn’t actually list off the missing fields just the default error message.

      Is there something else we need to do?
        • 33992 ☆ A M B ☆
        • 455 Posts
        WebloginPE does not specify the empty fields but you can modify the class to do that.
        the code below is this part in webloginpe.class.php line 445 - 479
        <?php
        if ($regRequired !== '')
        {
        	$requiredFields = explode(',', str_replace(' ,', ',', $regRequired));
        	foreach ($requiredFields as $field)
        	{
        		if ($field == 'formcode')
        		{
        			$formcode = $_POST['formcode'];
        			if ($_SESSION['veriword'] !== $formcode)
        			{
        				return $this->FormatMessage($this->LanguageArray[6]);
        			}
        		}
        		
        		if ($field == 'email')
        		{
        			// Validate the email address.
        			$this->ValidateEmail($_POST['email']);
        			if (!empty($this->Report))
        			{
        				return $this->report;
        			}
        		}
        		
        		if ($_POST[$field] == '' || empty($_POST[$field]))
        		{
        			if ($field == 'tos')
        			{
        				return $this->FormatMessage($this->LanguageArray[34]);
        			}
        			
        			return $this->FormatMessage($this->LanguageArray[0]);
        		}
        	}
        }
        ?>


        you can change the codes to something like this:
        <?php
        if ($regRequired !== '')
        {
        	$requiredFields = explode(',', str_replace(' ,', ',', $regRequired));
        	/* ------ */ $emptyFields = array();
        	foreach ($requiredFields as $field)
        	{
        		if ($field == 'formcode')
        		{
        			$formcode = $_POST['formcode'];
        			if ($_SESSION['veriword'] !== $formcode)
        			{
        				return $this->FormatMessage($this->LanguageArray[6]);
        			}
        		}
        		
        		if ($field == 'email')
        		{
        			// Validate the email address.
        			$this->ValidateEmail($_POST['email']);
        			if (!empty($this->Report))
        			{
        				return $this->report;
        			}
        		}
        		
        		if ($_POST[$field] == '' || empty($_POST[$field]))
        		{
        			if ($field == 'tos')
        			{
        				return $this->FormatMessage($this->LanguageArray[34]);
        			}
        			
        			/* ------ */ $emptyFields[] = $field;
        		}
        	}
        	
        	/* ------ */ return $this->FormatMessage($this->LanguageArray[0]) . "<br />Empty fields: " . join(" , ", $emptyFields);
        }
        ?>

        /* ------ */ signs have marked changed lines.
        Captcha, email and TOS fields have custom errors but for others, i collected them in an array ($emptyFields) and added them to end of error. The output will be like this:
        You have left some required form fields blank.
        Empty fields: name , age

        it is the the way that you should hack codes!
          God loves me. 【ツ】


          MODX.ir (Persian Support)

          Boplo.ir/modx/ (Persian)
          • 30228
          • 8 Posts
          Hi AHHP!

          Thanks for the reply, that was an great help. I actually tweaked it a tad to collect each error as a concatonated string and then send the string through the FormatMessage function so I get a bulleted list and can have more control over the output (so I don’t need to refer to the fields by the name of the input variables.

          Thanks again!
            • 15510
            • 70 Posts
            Hi, toddbloom7.

            Would you mind to do the same as AHHP and post your modifications to the thread? It will help the rest of the community if all users follow AHHP’s example.

            Many thanks.
              • 30228
              • 8 Posts
              Hello! Let’s see if I can get the modifications straight, since it’s been a while since I last touched the code:

              I simply commented out the code so I could compare the existing code to the code I changed but you can easily get rid of it, if you want. I also used the language file for the different error messages, but they should be self-explanatory. The end of the block just simply sends the error string to the FormatMessage function and prints everything out at the top.

              // Check for required fields.
              if ($regRequired !== '')
              {
              	$errorResponse = '';
              	$requiredFields = explode(',', str_replace(' ,', ',', $regRequired));
              	foreach ($requiredFields as $field)
              	{
              		if ($field == 'username' && $_POST['username'] == '' || empty($_POST['username']) || trim($_POST['username']) == '')
              		{
              			$error = "<strong>Username</strong> is a required field.";
              		}
              		if ($field == 'email' && strlen($_POST['email']) > 0)
              		{
              			$error = "<strong>Email address</strong> is a required field.";
              		}
              		if ($field == 'formcode')
              		{
              			$formcode = $_POST['formcode'];
              			if ($_SESSION['veriword'] !== $formcode)
              			{
              				$error = $this->LanguageArray[6];
              			}
              		}
              		
              		if ($field == 'email')
              		{
              			// Validate the email address.
              			if (!eregi("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,7}$", $Email))
              			{
              				$error = "The <strong>Email address</strong> you provided does not appear to be a properly formatted address.";
              			}
              		}
              		
              		if ($_POST[$field] == '' || empty($_POST[$field]))
              		{
              			if ($field == 'tos' && $_POST['tos'] != 'on')
              			{
              				$error = $this->LanguageArray[34];
              			}
              			if ($field == 'fullname')
              			{
              				$error = $this->LanguageArray[43];
              			}
              			if ($field == 'address')
              			{
              				$error = $this->LanguageArray[44];
              			}
              			if ($field == 'city')
              			{
              				$error = $this->LanguageArray[45];
              			}
              			if ($field == 'state')
              			{
              				$error = $this->LanguageArray[46];
              			}
              			if ($field == 'zip')
              			{
              				$error = $this->LanguageArray[47];
              			}
              			if ($field == 'phone')
              			{
              				$error = $this->LanguageArray[48];
              			}
              			if ($field == 'description_of_org')
              			{
              				$error = $this->LanguageArray[49];
              			}
              			
              			$errorResponse .= "<li>".$error."</li>";
              		}
              	}
              
              	if ($errorResponse != '')
              	{
              		return $this->FormatMessage($errorResponse);
              	}
              }
              
                • 15510
                • 70 Posts
                Thanks smiley

                This will help with my current project.