Welcome Guest, Not a member yet? Register   Sign In
Ag Auth - Custom Validation
#1

[eluser]bjuneau[/eluser]
I have Ag Auth up and running... However, I am a bit lost with how to wrap a <div> w/ specific styles around my validation messages? I'm somewhat familiar with PHP but still learning.

Below is what Ag Auth gives me by default for validation. I would like to place a <div></div> w/ the following styles around the form errors when they're called.

Code:
.errors {background-color: #F2F2F2;border: 1px solid #CCCCCC;color: #BE320D;padding: 10px;}

Code:
&lt;?php echo form_error('username'); ?&gt;
&lt;?php echo form_error('password'); ?&gt;

Thanks for the help, much appreciated!
#2

[eluser]bjuneau[/eluser]
Oh and not sure if this is the best way...

Code:
&lt;?php if(validation_errors()) : ?&gt;
    <div class="errors">
        &lt;?php echo form_error('username'); ?&gt;
        &lt;?php echo form_error('password'); ?&gt;
     </div>
&lt;?php endif; ?&gt;
#3

[eluser]bjuneau[/eluser]
So I have another question as I dive deeper into things...

I see with Ag Auth it places some, not all, of its error messages in the "message.php" (view) and not inline like the others... Sigh...

How can I have all error messaging coincide on the same page rather than loading a separate page?


In the "MY_Controller.php":

Code:
public function login($redirect = NULL)
{
  
  if($redirect === NULL)
  {
   $redirect = $this->ag_auth->config['auth_login'];
  }
  
  $this->form_validation->set_rules('username', 'Username', 'required|min_length[6]');
  $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]');
  
  if($this->form_validation->run() == FALSE)
  {
   $this->ag_auth->view('login');
  }
  else
  {
   $username = set_value('username');
   $password = $this->ag_auth->salt(set_value('password'));
   $field_type  = (valid_email($username)  ? 'email' : 'username');
  
   $user_data = $this->ag_auth->get_user($username, $field_type);
  
  
   if(array_key_exists('password', $user_data) AND $user_data['password'] === $password)
   {
    
    unset($user_data['password']);
    unset($user_data['id']);

    $this->ag_auth->login_user($user_data);
    
    redirect($redirect);
    
    
   } // if($user_data['password'] === $password)
   else
   {
    $data['message'] = "The username and password did not match.";
    $this->ag_auth->view('message', $data);
   }
  } // if($this->form_validation->run() == FALSE)
  
} // login()
#4

[eluser]Aken[/eluser]
I have no experience with Ag Auth, but you can change the HTML surrounding errors easily. http://ellislab.com/codeigniter/user-gui...delimiters




Theme © iAndrew 2016 - Forum software by © MyBB