Welcome Guest, Not a member yet? Register   Sign In
Form helper action
#1

[eluser]tatewaky[/eluser]
Regards,

The way i have been working with form helper is as fallow:

Code:
echo form_open('email/send');
echo form_submit('mysubmit', 'Submit Post!');

when i click 'mysubmit' button, as far as i understand, it will call my controller email on the method send, however, i would like to have an extra button on the same form but calling a diferent method as fallow:
Code:
echo form_open('email/send');
echo form_submit('mysubmit', 'Submit Post!');
echo form_submit('mySecondSumbit', 'Send email to everybody!');

Does anyone know the best way to do this, please i need a solution for this problem.
#2

[eluser]alrightythen[/eluser]
does it have to be a button? you can add an anchor() in the form and restyle the button and anchor to look the same.
something like this.. echo anchor('email/register', 'Register!, array('id' => 'registerbutton'))

then style both in your css file..
#registerbutton, input[type="submit"] {

border: none;
margin-right: 1em;
padding: 6px;
text-decoration: none;
font-size: 12px;
-moz-border-radius: 4px;
background: teal;
color: white;
box-shadow: 0 1px 0 white;
-moz-box-shadow: 0 1px 0 white;
-webkit-box-shadow: 0 1px 0 white;

}
#3

[eluser]tatewaky[/eluser]
[quote author="alrightythen" date="1258147548"]does it have to be a button? you can add an anchor() in the form and restyle the button and anchor to look the same.
something like this.. echo anchor('email/register', 'Register!, array('id' => 'registerbutton'))[/quote]

Does the anchor support the form submit???, i mean, when the user clicks on the anchor, and i get to register method, am i going to be able to work with the form validation class???
#4

[eluser]alrightythen[/eluser]
[quote author="tatewaky" date="1258147803"][quote author="alrightythen" date="1258147548"]does it have to be a button? you can add an anchor() in the form and restyle the button and anchor to look the same.
something like this.. echo anchor('email/register', 'Register!, array('id' => 'registerbutton'))[/quote]

Does the anchor support the form submit???, i mean, when the user clicks on the anchor, and i get to register method, am i going to be able to work with the form validation class???[/quote]

hmm I guess not.
Maybe you could do this..

in your view page
Code:
echo form_open('email/send');
echo form_submit('go', 'login');
echo form_submit('go', 'register');

in your controller
Code:
if($_POST['go']=="login") {
   $data = array(
                  'login' => $_POST['login'],
                  'pw' => $_POST['pw']
                   );
   $this->users_model->login($data);
}

if($_POST['go']=="register") {
   $data = array(
                  'login' => $_POST['login'],
                  'pw' => $_POST['pw'],
                  'date_registered' => date()
                   );
   $this->user_model->add_member($data);
}
#5

[eluser]tatewaky[/eluser]
Quote:hmm I guess not.
Maybe you could do this..

in your view page
<input type="submit" name="go" value="login">
<input type="submit" name="go" value="register">

in your controller
if($go == "login")
{
//login code
}
else
if($go == "register")
{
//register code
}

Thanks for your quick answers, i have already think in that solution, but i made this post anyway, because i think is a not elegant solution, post another answer if you come up with something, and again thank you very much for your answers.
#6

[eluser]alrightythen[/eluser]
I updated my previous post.. I don't think there's a more elegant way yet. good luck!




Theme © iAndrew 2016 - Forum software by © MyBB