Anth wrote:
Hi Earnie,
Thanks for the answer and that's one of the things to do, but my problem
at the moment with that path is that in hook_form_alter there doesn't
seem to be anything that I can use to identify which block it is. Am I
missing something obvious?
The third argument of hook_form_alter is the $form_id and for
user_login_block that would be user_login_block. Both $form and
$form_state are a pass-by-ref variable so any changes you do happen to
the form and/or form_state before they get rendered.
If there is nothing in the $form then what I think I actually want to do
is use some code to generate the form and as I have access to the $form
array to put in my own validation rule or hidden $form element or
whatever to distinguish between the different blocks.
You can add your own validation and submit handlers for the form using
hook_form_alter as well. You just need to make sure that your
hook_form_alter function uses a pass by ref for the $form parameter and
add your validation or submit handlers as appropriate.
So I'm trying to
generate the user_login_block myself so I can alter the $form array but
can't get it to work. In my block code if I call
drupal_get_form('user_login_block') for the block content everything is
fine but I can't alter the form object. So I'm trying to do the same
steps as drupal_get_form, i.e. the code below and the user login block
displays but there is a bunch of stuff missing from it so it doesn't
actually submit.
Am I making this harder than I need to for what I'm trying to achieve?
If you're doing the same code as drupal_get_form then you are most
likely doing the wrong thing and making it harder than it needs to be.
Be sure to look for the examples at api.drupal.org.
--
Earnie
-- http://progw.com
-- http://www.for-my-kids.com