Custom private message form - big questions

Permalink
Hello,
I am creating a combination of the profile page and messaging pages, and have a custom private message form with a generated recipient list instead of a passed variable. I based it on /profile/messages/write. To that end, I am combining the profile controller and the message controller, and added code to profile.php from single_pages/profile/messages.php. However I am getting non-object errors that are centered around error messaging and token validation - both are loaded by controller edit.php, which is extended by ProfileMessagesController (now added to controllers/profile/controller.php).

My (noob) questions are:
- Can I have multiple classes in a controller?
- If I am extending a class in another controller, how do I make sure the methods of that 'parent' controller get passed down? It seems to do that from edit controller->messages controller->messages view, but not when I copy that class to profile controller and run profile view.
-
Here is the relevant code: The two errors I am getting come from $error->output() and $vt->output('validate_send_message').

{code}
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php $this->inc('elements/header.php'); ?>
...
<div id="wrapper">
<?php $this->inc('elements/pagemeta.php'); ?>
<?php// echo $error->output(); // errors here ?>
<div class="mydashboard-block message-send">
<div class="mydashboard-header"><h4>Leave a Message</h4></div>
<div class="mydashboard-body"><!--<php Loader::element('/profile/message-center', array('profile'=> $profile));
?>-->
<?php
//$a = new Area('Column Two');
//$a->display($c);?>
<?$isAdmin=$profile->getAttribute('is_admin');?>
<?$isInstructor=$profile->getAttribute('is_instructor');?>

<form method="post" action="<?php echo $this->action('send?mode=1')?>">

<?php// echo $form->hidden("uID", $recipient->getUserID())?>
<?php echo "getTask: ".$this->controller->getTask()?>
<?php echo $form->hidden("uID")?>
<?php if ($this->controller->getTask() == 'reply') { ?>
<?php echo $form->hidden("msgID", $msgID)?>
<?php echo $form->hidden("box", $box)?>
<?php
$subject = t('Re: %s', $text->entities($msgSubject));
} else {
$subject = $text->entities($msgSubject);
}
?>

<h1><?php echo t('Send a Private Message')?></h1>

<div class="ccm-profile-section">
<label><?php echo t('To')?></label>
<!--<div><php echo $recipient->getUserName()?></div>-->
<select id="recipient_list" name="recipient_list">
<?php
//code here to build recipient list
?>
</select>
<?php $recipient = $_POST['recipient_list'];?>
<script>
$( "#recipient_list" ).change(function() {
$( "#uID" ).val($("option:selected", this).attr("val"));
});
</script>
</div>

<div class="ccm-profile-detail">
<div class="ccm-profile-section">
<?php echo $form->label('subject', t('Subject'))?>
<div><?php echo $form->text('msgSubject', $subject)?></div>
</div>

<div class="ccm-profile-section-bare">
<?php echo $form->label('body', t('Message'))?> <span class="ccm-required">*</span>
<div><?php echo $form->textarea('msgBody', $msgBody)?></div>
</div>
</div>

<div class="ccm-profile-buttons">
<?php echo $form->submit('button_submit', t('Send Message'))?>
<?php echo $form->submit('button_cancel', t('Cancel'), array('onclick' => 'window.location.href=\'' . $backURL . '\'; return false'))?>
</div>

<?php //echo $vt->output('validate_send_message'); // errors out here too ?>

</form>
</div>
</div>
{/code}

Any help is much appreciated - thanks!