Marcus
Well-known member
Your template could look like this.
1. You have to rename your function to actionChangedateSave. (the large "S" is the reason for the "-save" within the template: <form action="{xen:link 'posts/changedate-save', $post}")
2. You have to submit $post, so that the internal route in {xen:link} works:
This is the template andy_changedate:
$post.date is not configured. You can get the date along with other data in the controllerPublic function, currently $post is just set for $post['post_id']. ('title' and 'message_text' are useful, so that you can see the post on that tamplate before you change the date).
1. You have to rename your function to actionChangedateSave. (the large "S" is the reason for the "-save" within the template: <form action="{xen:link 'posts/changedate-save', $post}")
2. You have to submit $post, so that the internal route in {xen:link} works:
PHP:
<?php
class Andy_ChangeDate_ControllerPublic_Post extends XFCP_Andy_ChangeDate_ControllerPublic_Post
{
public function actionChangedate()
{
$post['post_id'] = $this->_input->filterSingle('post_id', XenForo_Input::UINT);
//echo 'ControllerPublic: Change Date. $postId = ' . $post['post_id'];
$viewParams = array('post' => $postId,
);
return $this->responseView('Andy_DateChange_ViewPublic_Post','andy_changedate',$viewParams);
}
public function actionChangedateSave()
..........................................................
}
This is the template andy_changedate:
PHP:
<xen:title>Date Change</xen:title>
<form action="{xen:link 'posts/changedate-save', $post}" method="post" class="xenForm AutoValidator" data-redirect="on">
<fieldset>
<dl class="ctrlUnit">
<dt><label>Date:</label></dt>
<dd><input type="text" name="title" size="30" value="{$post.date}" placeholder="Date..." class="textCtrl titleCtrl"></dd>
</dl>
<dl class="ctrlUnit submitUnit">
<dt></dt>
<dd><input type="submit" value="Change Date" class="button primary" accesskey="s" /></dd>
</dl>
</fieldset>
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>
$post.date is not configured. You can get the date along with other data in the controllerPublic function, currently $post is just set for $post['post_id']. ('title' and 'message_text' are useful, so that you can see the post on that tamplate before you change the date).