By AlexCogn on
Hi,
I'm changing the default log in module, and I want to have the 'Create account'-link to be a button.
I use this:
$form['actions']['create'] = array('#type' => 'button',
'#value' => t('Register'),
'#submit' => array('create_redirect'),
);
and
function create_redirect() {
drupal_goto("/user/register");
}
but when I click that button, instead of going to /user/register it goes to /node?destination=node
Comments
It's not working because it's never getting called
@Shadowstep0705, are you trying to completely override the original submit function or add an additional handler? If the latter, you need to change your code to
$form['#submit'][] = 'create_redirect_submit';If you are only wanting a redirect (that is you have no code before your drupal_goto()), a better option may be
$form_state['redirect'] = 'user/register';Looking to Migrate from Drupal 6/7 to Drupal 10/11? Have a look at our Drupal 11 demo site and request access.
try changung the button type
try changung the button type to submit instead of button
Need Drupal help?
Reach me
Backend Frontend and DevOps.
By both of them, I get an
By both of them, I get an error message, so I the URL will be /node?destination=node and in the footer there are two error messages:
Error message
Username field is required.
Password field is required.
At first I didn't see them but now I do. Ofcourse these two should be required when pressing the 'create' button
I want an additional
I want an additional redirect, which will be activated when clicking a second button. The main submit button will stay.
yeh you can have multiple
yeh you can have multiple button on a single from but if u are providing the submit handler for and element then the type of that button should be submit
Need Drupal help?
Reach me
Backend Frontend and DevOps.
What would be the point of
What would be the point of implementing a button if you can't specify any handler for it?
its a simple concept buddy u
its a simple concept buddy u can't submit a form on click of a element button to get the form submitted u have to specify element type as submit . in case of button u can invoke a javascript function that will submit ur fourm using javascript method submit
or else if u want to simply redirect to register page u can define anchor tag to do that rather than having a button there
Need Drupal help?
Reach me
Backend Frontend and DevOps.
Ah I see what you're doing now
I think you just need to add the following to your array:
'#executes_submit_callback' => TRUE,Looking to Migrate from Drupal 6/7 to Drupal 10/11? Have a look at our Drupal 11 demo site and request access.
Doesn't work
Doesn't work
Can you re-post your form code?
Can you re-post your form code as-is right now?
Looking to Migrate from Drupal 6/7 to Drupal 10/11? Have a look at our Drupal 11 demo site and request access.
Got it working
OK, I had to try it out for myself to see that both the required fields and authentication validation were causing issues, so I came up with something that worked:
Looking to Migrate from Drupal 6/7 to Drupal 10/11? Have a look at our Drupal 11 demo site and request access.