By srdrupal on
Hello everybody!
We need your help with thickbox module usage. We've used thickox to open user login form and it works fine when user submites correct data. But when the data submitted is not valid, user is redirected to the page user/login instead of keeping the thickbox open and showing error messages in it. Is there any idea what we should do about this?
Comments
Haven't tried this myself
Haven't tried this myself but should be possible to do using hook_form_alter() and $form['#redirect']
can you post
your solution as to how you made the login form work with thickbox??
or at least what you have accomplished so far?
thanks
To enable login form to
To enable login form to appear in thickbox, we've added thickbox module and in site configuration we've enabled it for login links.
But we have a problem of keeping the thickbox open until user submits correct username and password. If we make these changes in thickbox module, the result is that thickbox remains open but the form doesn't submit, namely we get inital state of the form again.
Here is our code:
thickbox.module:
function thickbox_form_alter($form_id, &$form) {
if ($form_id == 'user_login' && arg(0) == 'thickbox_login') {
$form['name']['#size'] = 25;
$form['pass']['#size'] = 25;
// we've added next line
$form['submit'] = array('#type' => 'button', '#value' => t('Log in'), '#weight' => 2, '#prefix' => '', '#sufix' => '', '#attributes' => array('tabindex' => '3'));
}
}
thickbox.js:
function tb_init(domChunk){
$(domChunk).click(function(){
//we've added this if condition
if(this.id=='TB_sendData'){
var newHref=this.href+'?KeepThis=true&height=350&width=500' + '&'+$('#TB_login_ajaxContent form').serialize();
this.href=newHref;
}
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
tb_show(t,a,g);
this.blur();
return false;
});
}
Does anybody know what sholud we use as newHref? Thanks!