简体   繁体   English

cakephp的问题

[英]Problems with cakephp

I have a form with multiple fields. 我有一个包含多个字段的表单。 Some file and input. 一些文件和输入。 I was working on it for some time. 我已经做了一段时间了。 Everything was working as it should be until a few hours back suddenly the form is not submitting to the right. 一切正常,直到几小时后表格仍未提交到右侧。 I have no idea what went wrong. 我不知道出了什么问题。 Action to submit the form is the same as the view it generated. 提交表单的操作与其生成的视图相同。 After i submit the form browser does not show anything default template address stays the same as the form submits to same view. 我提交表单后,浏览器不显示任何内容,默认模板地址与表单提交给同一视图的默认模板地址相同。 But i do have redirect statement if the data is saved correctly.. 但是我确实有重定向语句,如果数据保存正确。

As the form is submitted browser goes blank, not even the default template is shown ... and to add to my pain no errors ... Things are looking worse as they are.. So would really appreciate any pointers.. Thank You. 提交表单时,浏览器为空白,甚至没有显示默认模板...而且让我感到痛苦的是,没有错误...情况看起来更糟了。.因此,我们将不胜感激任何指针..谢谢。

A quick thing to check for is if there are any whitespace characters at the end of your models or controllers (actually, any .php file) after the '?>' That can cause the behavior you describe. 快速检查一下,在模型或控制器的末尾是否有空格字符(实际上是任何.php文件),这可能导致您描述的行为。

<?php
class YourController extends AppController {
    /*** your code here ***/
}

?>(whitespace chars here)

Something that I do that helps with this problem is to remove the '?>' on my models and controllers. 解决该问题的方法是删除模型和控制器上的“?>”。 The php interpreter will consider the EOF as the closing tag. php解释器会将EOF视为结束标记。

<?php
class YourController extends AppController {
    /*** your code here ***/
}

// END

@webbiedave has good advice too, cake has great debugging, although you may need to add the following to your layout template depending on which version of cake you are using... @webbiedave也有很好的建议,cake的调试效果很好,尽管您可能需要根据正在使用的Cake版本将以下内容添加到布局模板中...

<?php echo $this->element('sql_dump'); ?>

I put it right at the end of my default template 我把它放在默认模板的末尾

  1. Please post the code for the controller method that handles the form view. 请发布用于处理表单视图的controller方法的代码。
  2. Also post the <form action=... code. 还要发布<form action=...代码。
  3. If it isn't too long, also post the whole of the form html instead of (2.) 如果时间不太长,还可以发布整个html而不是(2.)。

With the code, we can help you debug the problem. 使用代码,我们可以帮助您调试问题。

To ensure that you can see any errors generated by PHP, open app/config/core.php in your editor and search for debug. 为确保您可以看到PHP生成的任何错误,请在编辑器中打开app/config/core.php并搜索调试。 Set the debug level to 2 - Configure::write('debug',2); 将调试级别设置为2- Configure::write('debug',2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM