Hi,

I have looked around and still have not been able to find a good solution for this.

I need to theme the user/edit page, and have all my extra profile fields on the same page. the form needs to submit, and edit the standard account information at the same time it edits the extra profile fields. (not two seperate forms).

So far I have tried to solve this using simular code to my registration page, which I found somewhere or other on the site.

my code is as below:

the problem with this it does not inject the 'GP Information' form fields as by default they are not part of this form. Anybody have any ideas what I can do to make this work for me? Or is there a beter/simpler solution?

function theme_user_edit($form) {

    foreach($form as $key => $value) { // loop through top level
    if (is_array($form[$key])) {
      $form[$key]['#title'] = '';
      $form[$key]['#description'] = '';
      foreach($form[$key] as $key2 => $value2) { // loop through second level
        if (is_array($form[$key][$key2])) {
          $form[$key][$key2]['#title'] = '';
          $form[$key][$key2]['#description'] = '';
        }
      }
    }
  }
  

  // Set up the Vars Array
  $vars = array();

  // Render Specific Fields You Want on Your Registration Form
  // note - the specific location of the element in the form array varies
  $vars['title_element'] = drupal_render($form['GP Information']['profile_title']);
  $vars['firstname_element'] = drupal_render($form['GP Information']['profile_firstname']);
  $vars['lastname_element'] = drupal_render($form['GP Information']['profile_lastname']);
  $vars['address_element'] = drupal_render($form['GP Information']['profile_address']);
  $vars['suburb_element'] = drupal_render($form['GP Information']['profile_suburb']);
  $vars['city_element'] = drupal_render($form['GP Information']['profile_city']);
  $vars['state_element'] = drupal_render($form['GP Information']['profile_state']);
  $vars['postcode_element'] = drupal_render($form['GP Information']['profile_postcode']);
  $vars['mail_element'] = drupal_render($form['account']['mail']);
  $vars['cpdnumber_element'] = drupal_render($form['GP Information']['profile_cpdnumber']);
  $vars['formid_element'] = drupal_render($form['account']['form_id']);

  // continue for each field you want...

  // Don't Forget the Submit Button 

  $vars['submit_button'] = drupal_render($form['submit']);
  

  $output =  _phptemplate_callback('user_edit', $vars);
  
  
 
  return $output;
}

Comments

drupalgeek’s picture

Yes, we can surely theme the user file , by using the below code n place this code in template.php

function phptemplate_node_form($form) {
if ($form['#node']->type == 'uprofile') {

return _phptemplate_callback('node-uprofile-edit', array('form' => $form));
}
then lastly create the file i.e. node-uprofile-edit.tpl.php

Drupalgeek
Ebizon technologies (http://ebizontek.com/)
India

asd123asd5’s picture

Hi,

thanks for your responce, does this require any custom modules?

bjacob’s picture

Hi there,
how did you manage it having only one page for the whole form? I couldn't figure it out. Having an own template for the user profile page is no problem but having the form on one page...

asd123asd5’s picture

yeah i failed at it and just settled for two pages. Though this seems like a bad way to do it. It would be best if all information could be edited on the main user/edit page.

I would still be interested if anybody had a solution to this.

MGParisi’s picture

Looks like it is to modify just the default user template. I have been looking for a solution to combined them too but I keep searching.

patricksettle’s picture

From what I can see there's no way to call a sub-category of the user-edit form through the Forms API. (e.g. The category specified by the Profile.module) And as these categories are not their own form (no profile-edit-form) I can't see a way of pulling that specific section to merge it with the default "account" category form elements.

I can pull the elements in via direct calls to profile_form_profile() or user_edit($category), but this doesn't load in the $edit data it seems, nor does it save the data put into the merged fields.

I've not found any info on how to pull the 'full' user-edit form (including all categories)...

I'm starting to think this is a flaw in the way user_edit works with Form API...

latte’s picture

Anybody figure this out. I am using Drupal 6.X and have not been able to find this out yet.

Any help would be appreciated.

Latte