My homepage has 2 different forms on it one for registering the user and one for the login. Both forms point to the same model but to different actions. The problem is that if you submit either form it will set off the action on the other form as well, so if I'm trying to login it will set off the registration action in the controller as if I was trying to register, for instance.
I already checked this solution but it seems overly complicated for something so simple, not to mention it will clutter my models folder with extra models that are pretty much useless except for a single action.
EDIT: I do not have this part of my project under Auth, I have admin routing and an admin section setup under Auth, but on the non-admin parts I'm using my own session handling and user validation.
Here is the code for my forms as well:
This is the registration form:
echo $this->Form->create('Fonyker', array('action' => 'add'));
echo $this->Form->input('username', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'id' => 'FonykerUsernameRegister',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Username',
'onsubmit' => 'return false;'
));
echo $this->Form->input('email', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Email',
'onsubmit' => 'return false;'
));
echo $this->Form->input('password', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'id' => 'FonykerPasswordRegister',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Password',
'onsubmit' => 'return false;'
));
echo $this->Form->input('name', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Name',
'onsubmit' => 'return false;'
));
?>
<div class="span-8 required">
<label for="FonykerBirthdate" class="inlined">From</label>
<input id="FonykerBirthdate" type="text" onsubmit="return false;" placeholder="Birthdate" name="data[Fonyker][birthdate]" class="datepicker input-text long" enabled="false">
</div>
<?php
$options = array('M' => 'M', 'F' => 'F');
$attributes = array(
'empty' => 'Gender',
'class' => 'input-combo span-8'
);
echo $this->Form->select('gender', $options, NULL, $attributes);
echo $this->Form->submit('',array(
'class' => 'signup-button',
'id' => 'signup-button'
));
echo $this->Form->end();
?>
And the login form:
echo $this->Form->create('Fonyker', array('action' => 'login'));
echo $this->Form->input('username', array(
'div' => array(
'class' => 'span-3'
),
'class' => 'input-text short',
'id' => 'FonykerUsernameLogin',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Username'
));
echo $this->Form->input('password', array(
'div' => array(
'class' => 'span-3',
),
'class' => 'input-text short',
'id' => 'FonykerPasswordLogin',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Password'
));
echo $this->Form->submit('',array(
'div' => array(
'class' => 'span-1'
),
'class' => 'login-button',
));
echo $this->Form->input('Fonyker.remember', array(
'div' => array(
'class' => 'span-3',
),
'type' => 'checkbox',
'label' => array(
'text' => 'Remember me',
'style' => 'margin-left:-10px;'
),
'value' => 'yes',
'class' => 'span-1'
));
echo $this->Html->link(__("Forgot it?", TRUE), array('controller' => "pages", 'action' => "recover_password" ), array('class' => 'span-2'));
echo $this->Form->end();
?>