On screens >=768px, everything works great. When a user inputs an incorrect username or password, the form fields glow red/yellow/green and get a little glyphicon toward the right side. If you resize smaller than 768px, it switches to the mobile view including a collapsible navbar (where my login form is). On the collapsed navbar, the feedback glyphicons are below the form fields rather than inside of them.
The PHP controls what state to make the fields after doing the login check against mysql. Lines like this <?php echo $form_error['user']; ?>
simply place the text 'has-success', 'has-warning', or 'has-error' in the class assignment. Similarly, the <?php echo $form_error['user_glyph']; ?>
lines will replace with <span>
tags for the glyphicon itself. (See the rendered source at the bottom if this is hard to follow)
Here is the source code I have for the nav:
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">BrandLogo</a>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" action="login.php" method="post">
<div class="form-group has-feedback <?php echo $form_error['user']; ?>">
<label class="sr-only" for="ip-username">Username</label>
<input type="text" placeholder="Username" class="form-control" name="username" id="ip-username" value="<?php echo $submitted_username; ?>" required/>
<?php echo $form_error['user_glyph']; ?>
</div>
<div class="form-group has-feedback <?php echo $form_error['password']; ?>">
<label class="sr-only" for="ip-password">Password</label>
<input type="password" placeholder="Password" class="form-control glyphicon-ok" name="password" id="ip-password" required/>
<?php echo $form_error['password_glyph']; ?>
</div>
<button type="submit" value="Login" class="btn btn-success">Log in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
And just to clarify any confusion, here is a rendered source after submitting an invalid password (showing only the <form>
block since nothing else is dynamic):
<form class="navbar-form navbar-right" action="login.php" method="post">
<div class="form-group has-feedback has-success">
<label class="sr-only" for="ip-username">Username</label>
<input type="text" placeholder="Username" class="form-control" name="username" id="ip-username" value="some-username" required/>
<span class="glyphicon glyphicon-ok form-control-feedback"></span>
</div>
<div class="form-group has-feedback has-error">
<label class="sr-only" for="ip-password">Password</label>
<input type="password" placeholder="Password" class="form-control glyphicon-ok" name="password" id="ip-password" required/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<button type="submit" value="Login" class="btn btn-success">Log in</button>
</form>
The CSS is unaltered bootstrap 3.1.1. How can I get the small view to work correctly like the other views?
Thanks in advance!