I'm creating a simple contact component in Joomla 3.3 (which is called Contact Pay).
I created a 'message' and a 'messages' view in the back-end, with associated models and controllers. 'message' is a JForm form, and 'messages' is the list view. Everything works fine there.
However in the front-end I only have a message view, for site visitors to send message. I use the same back-end model in the front-end, using
$controller->addModelPath( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_contactpay'.DS.'models' );
in the component entry file.
I simply copied the form XML file (message.xml) from the back-end, removed a few fields, and used it for the front-end. I output the form with the following layout file:
<form action="<?php echo JRoute::_( 'index.php?option=com_contactpay&task=message.save'); ?>"
method="post" id="contactpay-message-form" class="form-validate form-horizontal" enctype="multipart/form-data">
<fieldset>
<?php foreach( $this->form->getFieldset('message_fields') as $field ) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary validate"><?php echo JText::_('JSUBMIT');?></button>
<a class="btn" href="<?php echo JRoute::_('');?>" title="<?php echo JText::_('JCANCEL');?>"><?php echo JText::_('JCANCEL');?></a>
<input type="hidden" name="option" value="com_contactpay" />
<input type="hidden" name="task" value="message.save" />
<?php echo JHtml::_('form.token');?>
</div>
</form>
When a use fills out the form on the front-end it is saved to the database as it should be.
The Problem
The problem is that after the form is submitted it redirects to a 'messages' view which doesn't exist on the front-end, so I get the following error:
500 View not found [name, type, prefix]: messages, html, contactpayView
I tried controlling the redirect in the message controller which extends JControllerForm using the following code in the constructor:
$this->setRedirect( JRoute::_( 'index.php?option=com_contactpay&view=message' ));
However, this produces the same results.
How do control the component redirect?