I'd like to theme/template the form for my Profile2 profile type. I found this online but it doesn't seem to work:

function basic1_theme() {
return array(
'profile2_edit_my_info_form' => array(
'agruments' => array('form' => NULL),
'template' => 'templates/profile2-edit-my-info-form',
'render element' => 'form' ,
),
);
}

and

render($form['profile_my_profile']['field_my_field']);
print drupal_render_children ( $form ); 

What am I doing wrong?

Comments

infines’s picture

Category: support » bug
infines’s picture

Component: Code » Documentation
Assigned: Unassigned » infines

I've sort of found a way to do this, will be writing documentation!

sylenz’s picture

Category: bug » support

Got the same problem - how to create a template for the edit-site?
I guess, i have to hook it in the template.php file but how can this be done?

infines’s picture

So the initial issue of why this is so complicated is because the Profile2 form is attached to the user account settings form. There for there are a couple ways to skin this cat. If you want to change field sizes and text then I suggest Mustard Seed Medias screencast on hook_form_alter, which methods also work in template.php:

http://mustardseedmedia.com/podcast/episode53

If you're planning to do some drastic structural changes then I suggest learning about theming the user profile page. I accomplished this via setting up an if statement to detect which form was being displayed, the account settings form or profile2 form. If first detect the profile2 form and if it isn't then I print the account settings form. Here is my code:

<div id="user-settings">
	<?php if (isset($form['profile_portfolio'])): ?>
	<div class="portfolio-form">
		<?php print render($form['profile_portfolio']); ?>
	</div>
	<?php else: ?>
	<div class="settings-left">
		<?php print $account; ?>
	</div>
	<div class="settings-right">
		<?php print $picture; ?>
	</div>
	<div class="contact-settings">
		<h2>Contact & Notifications</h2>
		<?php print render($form['contact']); ?>
		<?php print render($form['field_hireme']); ?>
	</div>
	<?php endif; ?>
	<?php print drupal_render_children($form); ?>
</div>

I put this in my template.php file:

function THEMENAME_theme() {

$items = array();

$items['user_profile_form'] = array(
	'render element' => 'form',
	'path' => drupal_get_path('theme', 'THEMENAME') . '/templates',
	'template' => 'user-profile-form',
	'preprocess functions' => array(
		'folioh3_preprocess_user_profile_form'
	),
);

return $items;
}

If anyone else has any better ideas, let me know.

blogook’s picture

there is no other way than the suggested one in #44 ?

avpaderno’s picture

Assigned: infines » Unassigned
Priority: Critical » Normal
Issue summary: View changes
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.