[英]CodeIgniter: Load view with uri segment after form validation?
On my codeigniter site I have a list of users which an admin can create content for. 在我的codeigniter网站上,我列出了管理员可以为其创建内容的用户列表。 When creating new content for a user the url is example.com/content/new/ 5 .
在为用户创建新内容时,URL为example.com/content/new/ 5 。 5 being the ID of the user that the content is being created for.
5是为其创建内容的用户的ID。 When I submit the form and
form_validation
fails I reload the view but the problem is that it loses that last segment on the url with the ID number. 当我提交表单并且
form_validation
失败时,我会重新加载视图,但问题是它丢失了ID号在URL上的最后一段。 Is there a way I can reload the view with the errors and also keep that ID in the url? 有没有办法我可以重新加载带有错误的视图并将该ID保留在url中?
Here is my code... 这是我的代码...
if ($this->form_validation->run() == FALSE){
$this->load->view('create_content', $data); //reload if validation fails
} else {
//prepare data for the database here
}
One of the ideas is to post to the same URL eg use current_url()
想法之一是发布到相同的URL,例如使用
current_url()
<?php echo form_open(current_url()); ?>
https://www.codeigniter.com/user_guide/helpers/url_helper.html https://www.codeigniter.com/user_guide/helpers/url_helper.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.