2

I have a page (user profile.tpl.php) with a custom form and a view embedded in the tpl.php file.

The custom form is defined in a custom module, with validation and submit hooks, and the view is being displayed programatically like so:

$view = views_get_view('accounts_for_user');
$view->set_display('panel-pane-1');
$view->set_exposed_input(array('field_customer_number_uid' => $user->uid));
echo $accountsView->preview();

The form is also being displayed programatically (in a jquery ui dialog):

echo drupal_render(drupal_get_form('custom_mod_change_password_form'));

This is my validation hook:

function custom_mod_change_password_form_validate($form,&$form_state)
{    
    $oldPassword = $form_state['input']['old-password'];
    $newPassword1 = $form_state['input']['new_pass1'];
    $newPassword2 = $form_state['input']['new_pass2'];

    if ($newPassword1 != $newPassword2)
    {
        form_set_error('old-password',t("Password and confirm password do not match."));
    }
    global $user;
    $account = user_load($user->uid);
    if (!user_check_password($oldPassword,$account))
    {
        form_set_error('new_pass1',t("Old password is invalid."));
    }
}

Now this works on initial load and displays fine. The problem is that when there is a validation error, the view shows it's no result message instead of the actual fields.

Any ideas on what might be the problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.