User Profile Edit form

Public

user-profile-edit.tpl.php

Get raw version
php
  1. <section class="separator-grain separator group">
  2. <?php
  3. kpr($form);
  4. //TODO: user drupal_render, drupal_render_children and preprocess functions
  5. print '<h2 class="green-light separator-padded separator-dashed-bottom">'; print t('Your details:'); print '</h2>';
  6. print render($form['account']['mail']);
  7. print render($form['account']['name']);
  8. ?>
  9. <div class="form-item form-type-textfield form-item-picture">
  10. <?php
  11. print '<label>'; print t('Your photo:'); print '</label>';
  12. print render($form['picture']['picture_current']);
  13. ?>
  14. </div>
  15. <?php
  16. print render($form['picture']['picture_delete']);
  17. print render($form['picture']['picture_upload']);
  18. ?>
  19. </section>
  20. <section class="group">
  21. <?php
  22. print '<h2 class="green-light">'; print t('Reset your password:'); print '</h2>';
  23. print render($form['account']['current_pass']);
  24. print render($form['account']['pass']);
  25. print render($form['account']['pass2']);
  26. ?>
  27. </section>
  28. <?php
  29. print render($form['form_build_id']);
  30. print render($form['form_id']);
  31. print render($form['form_token']);
  32. print render($form['actions']);
  33. print render($form['#validate']);
  34. ?>

template.php

Get raw version
php
  1. function theme_preprocess_user_profile_form(&$vars) {
  2. drupal_set_title('Account settings');
  3. unset($vars['form']['account']['name']['#description']);
  4. $vars['form']['account']['name']['#title'] = t('Username:');
  5. unset($vars['form']['account']['mail']['#description']);
  6. $vars['form']['account']['mail']['#title'] = t('Email:');
  7. $vars['form']['picture']['#title'] = t('Your photo:');
  8. $vars['form']['picture']['picture_upload']['#title'] = t('Upload new photo:');
  9. $vars['form']['picture']['picture_upload']['#attributes']['class'][] = 'form-text';
  10. unset($vars['form']['picture']['picture_upload']['#description']);
  11. unset($vars['form']['account']['current_pass']['#description']);
  12. unset($vars['form']['account']['pass']['#description']);
  13. unset($vars['form']['account']['pass2']['#description']);
  14. $vars['form']['account']['pass']['pass1']['#title'] = t('New password:');
  15. $vars['form']['account']['pass']['pass2']['#title'] = t('Re-enter new password:');
  16. $vars['form']['actions']['submit']['#value'] = t('Save changes');
  17. $vars['form']['actions']['submit']['#attributes']['class'][] = 'btn';
  18. $vars['form']['actions']['submit']['#attributes']['class'][] = 'btn-purple';
  19. }

Comments

waako's picture

I can see how it makes more sense, but out of interest, what exactly is wrong with this method?
I wish I could remember where I got this method from, then could go look at it again now.

laniol's picture

Sometimes using .tpl.php is easier, especially you dont want to explain whole drupal theming layer to a frontent guy.