Okay so Im pretty sure I've missed something important in my preprocess function for the node_form of one of my profile content types.
Or I have found a bug... lol most likely the first! ^_^

I have a cck content_type setup as available to users profile ... per your instructions....within that is only a few cck fields
...........the main being an "add and reference" popup node_reference {select-box & popup adder} which gets select list from a view.
I can create as many of these referenced nodes as I want (in my use case these are computers we support for a given client) the popups work great and the view is properly pulling only the current profiles user's nodes of this profile_type which they can multi-select to be displayed in their profile.
I want this later part to be gone and auto select the nodes for reference but alas thats going to have to be after I fix my current issue! lol

The next step I took was to create a custom tpl and a preprocess function in my template.php to control the view of the edit form.
Everything works great as long as $vars['whole_form'] = drupal_render($vars['form']); is used.

As soon as I start using $vars to call specific fields the users profile edit screen for this profile_type looses its connection to the node data and shows up as an empty form even though the node data is still in the db.

Consequently when I fill that empty form out ... obviously I get the "This user already has a content profile of this type. You can only create one profile per user."

What am I missing in my preprocess function below to make sure all important values are present and the form pulls the existing data from the db?
Ive included my code below ...

template.php

function mytheme_theme (){
	return array(
		'profile_member_node_form' => array(
			'arguments' => array('form' => NULL),
			'template' =>  'profile-member-node-form',
		),
		'contact_mail_page' => array(
			'arguments' => array('form' => NULL),
			'template' => 'contact-form',
		),
	);
}

function mytheme_preprocess_profile_member_node_form(&$vars) { 
	//dsm($vars['form']);
	$vars['title'] = drupal_render($vars['form']['title']);
	$vars['checkout'] = drupal_render($vars['form']['checkout']);
	 $vars['uid'] = drupal_render($vars['form']['uid']);
	 $vars['nid'] = drupal_render($vars['form']['nid']);
	$vars['field_user_computers'] = drupal_render($vars['form']['field_user_computers']);
	$vars['vertical_tabs'] = drupal_render($vars['form']['vertical_tabs']);
	$vars['buttons'] = drupal_render($vars['form']['submit']);
	//$vars['whole_form'] = drupal_render($vars['form']);
}

profile-member-node-form.tpl.php

<div class="content">
 <div class="dialog">
  <div class="contents">
   <div class="t"></div>

	<h3>This is the user edit profile member tpl chingus, If you see this its working.</h3>
	
	<?php print $title; ?>
	
	<?php print $field_user_computers; ?>
	
	<?php print $buttons; ?>
	
	<?php //print $whole_form; ?>
	
	<?php print drupal_render($form); //IMPORTANT! ?>
	
   </div>
  <div class="btm"><div></div></div>
 </div>
</div>

<?php
print '<pre>';
print htmlspecialchars(print_r(content_fields(NULL, 'profile_member')));
print '</pre>';
?>

Comments

cluke009’s picture

I am having the same problem any one have an idea where to start with this?