symfony 1.4 twitter bootstrap login -
i have old working login form in symfony 1.4.each field displayed using symfony helpers(renderlabel).
<form action="<?php echo url_for('core/login') ?>" method="post" class="form-signin"> <div class="alert-error"> <?php if(!empty($error)): ?> <span class="error"><?php echo $error ?></span><br /><br /> <?php endif; ?> </div> <h2 class="form-signin-heading">welcome company</h2> <legend>please sign-in</legend> <?php echo $form['username']->renderlabel() ?><br /> <?php echo $form['username'] ?> <?php if($form['username']->haserror()): ?> <span class="error"><?php echo $form['username']->geterror() ?></span> <?php endif; ?> <br /> <?php echo $form['password']->renderlabel() ?><br /> <?php echo $form['password'] ?> <?php if($form['password']->haserror()): ?> <span class="error"><?php echo $form['password']->geterror() ?></span> <?php endif; ?> <br /> <button class="btn btn-lg btn-primary btn-block" type="submit" value="login" >login</button> </form>
but modify , add "handsome" looks need replace form this.
<h1 class="text-center login-title">some company</h1> <p class="text-center">please sign-in</p> <input type="text" name="username" class="form-control" placeholder="username" required autofocus > <input type="password" name="password" class="form-control" placeholder="password" required> <button class="btn btn-lg btn-primary btn-block" type="submit" value="login">sign in</button>
what possible ways in modifying login form ? need modify login form .
got it..i hardcoded accomplish..in loginform.class.php
<?php class loginform extends baseform { public function configure() { $this->setwidgets(array( 'username'=>new sfwidgetforminputtext(array(), array('size'=>32, 'class'=>'form-controll','placeholder' => 'username')), 'password'=>new sfwidgetforminputpassword(array(), array('size'=>32, 'class'=>'form-controll','placeholder' => 'password')) )); $this->widgetschema->setnameformat('login[%s]'); $this->setvalidators(array( 'username'=>new sfvalidatorstring(array('max_length'=>50)), 'password'=>new sfvalidatorstring() )); $this->widgetschema->setlabels(array( 'username'=>'username', 'password'=>'password' )); }
}
then added custom css form-controll class
<style> .form-controll{position:relative;font-size:16px;height:auto;-webkit-box-sizing:border- box;-moz-box-sizing:border-box;box-sizing:border-box;padding:10px;}
.form-controll:focus{z-index:2;}
then in templates
<script> $(document).ready(function(){ settimeout(function() { $("#flip").fadetoggle(2000);},2000) }); </script> <div class="container" id="divcon"> <div class="row"> <div class="col-sm-6 col-md-4 col-md-offset-4"> <div class="account-wall"> <img class="profile-img" src="https://lh5.googleusercontent.com/-b0- k99fzlye/aaaaaaaaaai/aaaaaaaaaaa/eu7opa4byxi/photo.jpg?sz=120" alt="solidbond"> <?php if(!empty($error)): ?> <div class="modal-body" id="flip"> <?php echo $error ?></div><br /><br /> <?php endif; ?> <?php if($form['username']->haserror()): ?> <div class="modal-body" id="flip"> <?php echo $form['username']->geterror() ?> </div> <?php endif; ?> <?php if($form['password']->haserror()): ?> <div class="modal-body" id="flip"> <?php echo $form['password']->geterror() ?> </div> <?php endif; ?> <form action="<?php echo url_for('core/login') ?>" method="post" class="form-signin"> <h1 class="text-center login-title">company</h1> <p class="text-center">please sign-in</p> <?php echo $form['username'] ?><br /> <?php echo $form['password'] ?><br /> <button class="btn btn-lg btn-primary btn-block" type="submit" value="login">sign in</button> <label class="checkbox pull-left"> <input type="checkbox" value="remember-me"> remember me </label> <a href="#" class="pull-right need-help">need help? </a><span class="clearfix"></span> </form> </div> <a href="#" class="text-center new-account">maintained by: </a> </div> </div>
i wrote piece of j query separate form errors in username , password fields..
Comments
Post a Comment