2

I am using this code to make the user_profile_form available on my user-profile.tpl.php so the user profile filed can be edited directly from the sure page.

function parce_preprocess_user_profile(&$variables) {
  $variables['user_edit']  = drupal_get_form('user_profile_form', menu_get_object('user'));
}

Then, I can correctly print them individually using this code:

<?php print drupal_render($user_edit['account']['mail']); ?>

It works fine, but the problem is that the <form> tag doesn't appear on the page, and the form doesn't submit. When I add it manually in the template page, it works, but I was wondering how to get Drupal to insert these tags automatically.

I tried something like this (out of pure guess):

function parce_theme($existing, $type, $theme, $path){
  return array(
    'user_profile_form' => array(
      'render element' => 'profile_edit',
      'template' => 'user-profile',
    ),
  );
}

It doesn't work. Am I doing anything wrong?

1
  • I am not clear why you would show the edit form at every user profile page.
    – apaderno
    Commented Jun 25, 2011 at 11:38

2 Answers 2

2

You have to render the full form, so drupal_render($user_edit) is needed.

2
  • Thanks for your answer Daniel, but when i do that the form tag is being printed of the page but now my form elements are not within the Form Tag. Basically i end up with <form .... > </form> Then my form inputs
    – silkAdmin
    Commented Jun 20, 2011 at 8:33
  • Still not working, when i do this the form element that i am printing end up outside the <form> tags
    – silkAdmin
    Commented Jun 24, 2011 at 7:41
0

I didn't find a way around that; I ended up printing the form tag manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.