1778 Posts in 581 Topics by 555 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1130 Views |
-
Form action uses form name instead?

3 February 2011 at 1:17am
Maybe it's just me, because I've been coding all night until the wee hours. =) But I'm confused as to why, when I create a form of my own, it uses the form name as the action url?
function SignupForm() {
$fields = new FieldSet(
new EmailField('Email', 'E-mail Address')
);
$action = new FieldSet(new FormAction('signup', 'Sign Up'));
return new Form($this, 'SignupForm', $fields, $action);
}will output this in the page:
<form id="Form_SignupForm" action="/project/home/SignupForm" method="post" enctype="application/x-www-form-urlencoded">
Shouldn't it be this?:
<form id="Form_SignupForm" action="/project/home/signup" method="post" enctype="application/x-www-form-urlencoded">
I tried doing this instead:
$form = new Form($this, 'SignupForm', $fields, $action);
$form->setFormAction($this->link('signup'));
return $form;but that returns a server error. The former problem just returns you a "page not found" error.
-
Re: Form action uses form name instead?

4 February 2011 at 3:45pm
No it is standard for it to call the Form Name in the URL. When you submit the form it goes back through the form function creating the form object for the save request.
If you want to redirect to a 'nice' url after submitting the form do this in your form processing function.
-
Re: Form action uses form name instead?

4 February 2011 at 3:48pm
Ah, no, I wasn't looking to do that. I was just curious about why it processes this way.
I was getting "[Warning] Missing argument 2" errors for the $form variable when using the $allowed_actions array with the form in 2.4.4+ up and this had me mystified because I was setting up the form correctly, but then I read the changelog for 2.4.4 and discovered the change related to forms and $allowed_actions. Worked fine after I tweaked for that.
| 1130 Views | ||
|
Page:
1
|
Go to Top |


