views:

562

answers:

4

Hello,

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;}
.licitateThis 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.

A: 

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()')); ?>
Galen
if i put: '<?php echo $html->link(__('Sign In', true), array('type' => 'Sign In', 'class'=>'licitate', 'onClick' => 'document.UserLoginForm.submit()')); ?>' the html generated is '<a href="/bids/sales/index/type:Sign In/class:licitate/onClick:document.UserLoginForm.submit()">Sign In</a>' and it doesn't work.
NoOne
The parameters are just wrong that's all. Check the link method in the docs.You'll want, echo $html->link(__('Sign In', true), null, array('class'=>'licitate', 'onClick'=>'this.submit();'));Docs, http://api.cakephp.org/class/html-helper#method-HtmlHelperlink
DavidYell
You do not have to use the `onclick` attribute embedded directly into the link, in fact, it's bad form. The JavaScript functionality should be attached as a progressive enhancement.
Justin Johnson
if I do the way you said i got this error: "Error: The requested address '/<CURRENT_CONTROLLER>/Sign In' was not found on this server.". This form im trying to submit its a login form and it can be used in every views once its located at default.ctp. :S
NoOne
if he uses a link for the form then progressively enhancing it means nothing since the link without js won't submit the form anyways.Progressive enhancement is enhancing something with js THAT ALREADY WORKS AS EXPECTED WITHOUT IT. It isn't progressive enhancement if the functionality REQUIRES js to work. In that case an inline submit handler is both fine, semantically correct and easier to spot in the markup as an exception to normal behavior rules.
Abba Bryant
A: 

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.

jpdelatorre
Also possible to use <input type="submit" value="Sign In" /> instead of <button> tag.
jpdelatorre
I have a css costumization called licitation and i wan't to use it on my submit button, but I don't know how. :S
NoOne
you can still do so on `<button type="submit" class="licitate">Sign In</button>`. You just need to tweak your CSS a bit. Try removing the `a` on `a.licitate` definition on CSS.Although you'll need to use javascript instead of :hover for the mouseover effect
jpdelatorre
Thats correct... I changed a litle bit the CSS and its now working, and the hover too (without js). Thanks
NoOne
A: 

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( );
Abba Bryant
Yes thats my problem, but there is another one: the class licitate is for a anchor, it has a normal state and a hover state. Here it is a extract of my CSS: http://pastebin.com/m4116430 and a normal link using that css styles: http://pastebin.com/m2f7af7ab .
NoOne
So, you don't have a real problem. What you have is not enough knowledge of css to style a button element the way you want and a bit of css you wish could work on an element it wasn't meant to work for.Why not google around for how to style button elements. A good starting point is the buttons plugin from blueprintcss.orgWhy are you wrapping a span around an anchor tag? There are much cleaner and semantically better ways to do this. Even something as simple as putting the classname on the anchor tag, and wrapping your link text in the span would be an improvement.
Abba Bryant
A: 

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>
streetparade
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.
NoOne