Using html link as form button
I have a login form where a user (that is not logged yet) can insert his login and password, after filling these fields the user has to press a submit button.
What i'm trying to do is: Replace the normal submit button for a $html->link with some css styles.
So is there anyway I can use something like this:
<span class = "licitateThis clearfix">
<?php echo $html->link(__("Sign In", true), array("type" => "Sign In", 'class'=>'licitate')); ?>
</span>
Instead of:
echo $form->end(__('Sign In',true));
to create a submit button for a small login form?
My css code:
.licitateThis{position:relative;float:left;width:100%;}
.licitateThis a.licitate{display:block;float:left;padding:2px 0 4px;width:100%;background-color:#eee;text-shadow:#fff 1px 1px 1px;text-decoration:none;font-weight:bold;font-size:115%;border:1px solid #fff;border-radius:3px;text-align:center;letter-spacing:-0.02em;text-transform:uppercase;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}
.licita开发者_开发技巧teThis a.licitate:hover,.licitateThis:hover a{background-color:#0071bb;text-shadow:#666 1px 1px 1px;color:#fff;}
PS: The form im trying to submit its a login form, and its located at default.ctp so it can be used in every pages.
Problem solved:
CSS (created a new class):
.loginSubmit {color:#0071bb;outline:none; display:block;float:left;padding:2px 0 4px;width:100%;background-color:#eee;text-shadow:#fff 1px 1px 1px;text-decoration:none;font-weight:bold;font-size:115%;border:1px solid #fff;border-radius:3px;text-align:center;letter-spacing:-0.02em;text-transform:uppercase;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}
.loginSubmit:hover {background-color:#0071bb;text-shadow:#666 1px 1px 1px;color:#fff;}
PHP:
<button type="submit" class="loginSubmit">Sign In</button>
<?php echo $form->end(); ?>
Thanks.
What are you trying to do here? Any reason why you need to use anchor <a>
tag for your submit button?
If all you want is to make your submit button look like a link, then you can do that using css.
Or if you just want to put your submit button somewhere else other than beside the </form>
tag, then you can just put <button type="submit" class="licitate">Sign In</button>
anywhere inside the form and use <?php echo $form->end(); ?>
to close the form.
His problem is that an anchor tag can't submit the form without javascript. $html->link makes a link, not a input type of submit, not a button of type submit.
If you want to simply use a button, write the CORRECT html for it by hand.
... other form code here
<button type="submit" class="licitation">
Sign In
</button>
<?php echo $form->end( );
if i understand the wuestion right you want to try if your user is already logged in ? if so first create a function which checks if a user is logged in or not. Then check it
<span class = "licitateThis clearfix">
<?php if(userisalreadyloggedin())
echo '<a href="login.php" class ="licitate"> Singin</a>';
?>
</span>
yes but it's usually not a good idea. you are going to have to use javascript..
<a href="#" onclick="document.formName.submit()">
with cakephp maybe
<?php echo $html->link(__("Sign In", true), array("type" => "Sign In", 'class'=>'licitate', 'onClick' => 'document.formName.submit()')); ?>
精彩评论