Score:0

Templating the user edit page

us flag

i'm using the theme startupgrowth lite and i want to theme my user edit page , only when the user is a 'testeur' and he's editing the 'candidate user profile'.

i know that when i want to modify the form i must do this step:

1- add function to template.php to override the template page:

 function startupgrowth_lite_theme($existing, $type, $theme, $path) {
$items['user_profile_form'] = array(
    // Forms always take the form argument.
        'arguments' => array('form' => NULL),
        'render element' => 'form',
        'template' => 'page--user--edit',
        'path' => drupal_get_path('theme', 'startupgrowth_lite') . '/template/form',
);
return $items;
}

2- After that i must create a folder /template/form/ and put my file page--user--edit.tpl.php on it and start coding in.

3- flush cache and you will have the render, if not that you must make the administration theme like your theme by default on my case (startupgrowthup theme).

But in normal case, i must write on code <?php print render($form['XXX']); ?> to have the field of user_profil_form named 'XXX'.

All 2steps works good but i don't know how to have the field of form on my page to modify all informations like i want to expose.

this is a screenshot that how i want to expose my page edit user.enter image description here

Score:0
us flag

Well my solution for this, is to make a function on a custom module and print out my code directly to the page.

function custommodule_form_alter(&$form, $form_state, $form_id) {
  global $user;
  if($form['#form_id'] == "user_profile_form" && in_array('administrator', $user->roles)){
    echo $form['form_id']['#value'];
    print render($form['field1']);
    print render($form['field2']);
  }
  dpm($form);
}

PS: I use this to modify the user form only for some rules on my project. Here I choose administrator to see only field1 and field2 from all the form fields for example.

in_array('administrator', $user->roles)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.