0

I am trying to theme the user profile edit page using user_profile_form() and need help how to achieve this. In my template.php I have the following code:

function marinelli_theme($existing, $type, $theme, $path) {
  $hooks['user_profile_form'] = array(
    // Forms always take the form argument.
    'arguments' => array('form' => NULL),
    'render element' => 'form',
    'path' => drupal_get_path('theme','marinelli'),
    'template' => 'templates/user-profile-edit',
  );
}

function marinelli_preprocess_user_profile_form(&$variables) {
  global $user;
  $form_id = 'user_profile_form';
  $form_state = array();
  $form_state['build_info']['args'] = array($user);

  // Load user.pages.inc and ensure it is automatically reloaded if
  // this form is rebuilt via AJAX or other means.
  form_load_include($form_state, 'inc', 'user', 'user.pages');

  $variables['rendered'] = drupal_build_form($form_id, $form_state);
}
0

1 Answer 1

1

Here is the code you need to follow:-

function THENAME_theme(&$existing, $type, $theme, $path) {

return array(
    'edit_profile_user_profile_form' => array(
        'arguments' => array('form' => NULL),
        'template' => 'templates/edit/user-profile',
        'render element' => 'form',
        ),
);
}

Next thing You need to create a file called user-profile.tpl.php and save it in template folder.

In the user-profile.tpl.php file, write the following code to print out the fields:

<?php print drupal_render($form['field_NAME_OF_FIELD']); ?>

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.