The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Registration: non-required fields - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Registration: non-required fields (/showthread.php?tid=189)



Registration: non-required fields - spike - 07-19-2016

M.b. i'm wrong, but there is no check for required rule value, so every registration field is required.

take a look at join.php. Field 'company' isn't required, but without filling in your get an error "Company Name is required"

<pre>
Code:
    $validation->check($_POST,array(
      'username' => array(
        'display' => 'Username',
        'required' => true,
        'min' => 5,
        'max' => 35,
        'unique' => 'users',
      ),
      'fname' => array(
        'display' => 'First Name',
        'required' => true,
        'min' => 2,
        'max' => 35,
      ),
      'lname' => array(
        'display' => 'Last Name',
        'required' => true,
        'min' => 2,
        'max' => 35,
      ),
      'email' => array(
        'display' => 'Email',
        'required' => true,
        'valid_email' => true,
        'unique' => 'users',
      ),
      'company' => array(
        'display' => 'Company Name',
        'required' => false,
        'min' => 0,
        'max' => 75,
      ),
      'password' => array(
        'display' => 'Password',
        'required' => true,
        'min' => 6,
        'max' => 25,
      ),
      'confirm' => array(
        'display' => 'Confirm Password',
        'required' => true,
        'matches' => 'password',
      ),
    ));
</pre>





If we add some check in validate.php, registration run smooth without filling company field:
<pre>
Code:
                if ($rule === 'required' && empty($value)) {
                    $this->addError(["{$display} is required",$item]);
                } else if(!empty($value)){
</pre>




replace with
<pre>
Code:
                if ($rule === 'required' && $rule_value === true && empty($value)) {
                    $this->addError(["{$display} is required",$item]);
                } else if(!empty($value)){
</pre>



Registration: non-required fields - mudmin - 07-24-2016

I'm not looking at the code in front of me, but some of the validation is being done in HTML and some is done through the validation class. I'll try to take a look at this.