- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个组件,它有一个名为 MyproductControllerGeneralsetting
的 Controller ,它扩展了 JControllerForm
。在 MyproductControllerGeneralsetting
中,我正在覆盖父类中的 save
方法以修改 $_POST
数据,然后覆盖方法调用父类' save
方法进行实际保存。
下面是 MyproductControllerGeneralsetting
中的重写方法:
/**
* We overwrite the saved form data and trim them to avoid spaces
*/
public function save($key = null, $urlVar = null){
if($_POST['jform']){
foreach($_POST['jform'] as $key=>&$value){
$value = trim($value);
}
}
// Finally, save the processed form data (calls JControllerForm-save())
parent::save('id', $urlVar);
}
问题是,即使我已经在这个覆盖方法中修剪了每个 POST 数据字段,如果我提交了一些值,例如“value”(注意末尾的空格),它们不会被修剪。
我检查了 JControllerForm
类的 save
方法,它似乎是从这里的 POST 获取数据:
$data = $this->input->post->get('jform', array(), 'array');
也许这就是原因?这是在获取缓存数据还是什么?
最佳答案
与其尝试直接从 $_POST
获取值,不如尝试以与父类相同的方式获取和设置数据 - 使用指向 JInput 的(共享)实例的内部指针类。
这是一个修改过的、有效的、覆盖的save
方法:
/**
* We overwrite the saved form data and trim them to avoid spaces
*/
public function save($key = null, $urlVar = null){
if($_POST['jform']){
// Get the original POST data
$original = JRequest::getVar('jform', array(), 'post', 'array');
// Trim each of the fields
foreach($original as $key=>$value){
$original[$key] = trim($value);
}
// Save it back to the $_POST global variable
JRequest::setVar('jform', $postData, 'post');
}
// Finally, save the processed form data
return parent::save('id', $urlVar);
}
关于joomla - 覆盖 JControllerForm save() 方法以修剪 POST 数据没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16280955/
在字符串 (\test.something) 之后删除所有内容的命令是什么。 我在文本文件中有信息,但是在字符串之后有 1000 行我不想要的文本。如何删除包括字符串在内的所有内容。 这就是我所拥有的
我想删除每个项目的空白.amount 我在 .amount 类上使用 trim 和 each,但它似乎不起作用: jQuery('.amount').each(function(){ jQue
我列出了以下正在稳步增加的点,例如: [[0, 0], [9, 4], [18, 19], [25, 34], [48, 48], [54, 53], [61, 65], [69, 82], [73,
清理自动生成的 html 带来更多乐趣。标签中注入(inject)了大量无关的空格: Lorem Ipsum dolor sit... ( 代表实际空间,而不是实
计算 trimmed 的有效方法是什么?或winsorized列表的标准差? 我不介意使用numpy,但如果我必须制作列表的单独副本,它会非常慢。 最佳答案 这将制作两个副本,但您应该尝试一下,因为它
这个问题在这里已经有了答案: 关闭10 年前。 Possible Duplicate: Leave only two decimal places after the dot Formatting
我正在使用绑定(bind)来填充 Listbox,其中包含 TextBlock 等。 问题是: 如何确保绑定(bind)到 TextBlock 的 Text 属性的文本具有特定长度,或者它是显示为某些
我正在按以下方式修剪 NSString: NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:
我有一个文本列,其内容在字符串的前后混合了换行符和空白字符。我正在尝试编写一个 SELECT 语句,它向我显示没有前导和尾随垃圾的内容。 以下查询修剪空格: SELECT TRIM(column) F
这个问题在这里已经有了答案: How to slice a pandas DataFrame by position? (5 个答案) 关闭 5 年前。 我似乎看不出这里有什么问题。我有一个长度为
我没有找到类似的问题可能是因为我没有找到正确的词(英语不是我的母语) 问题 我有一个 varchar 值,末尾有一个空格:"opt-193-381-markets " 当我执行 SELECT 的值没有
假设我有 $url="../folder/file",我想找到并删除 ../ 部分。 我正在使用 trim() ...... $url = trim($url,"../"); ……但它给了我一个警告:
这个问题在这里已经有了答案: Java String trim has no effect (7 个答案) string trim function is not working [closed]
我有以下 XML: tag:search.twitter.com,2005:22204349686 如何将第二个冒号后的所有内容写入变量? 例如22204349686 最佳答案 if(preg_mat
修剪在深度优先搜索中什么时候停止有效?我一直在研究一种有效的方法来解决 N-Queens 问题,并且我第一次关注修剪。我已经为前两行实现了它,但它什么时候停止有效?我应该修剪多远? 最佳答案 N 皇后
我有一个图表,按天将两种类型的数据制成表格,我希望只修剪图表中的第一个和最后一个标签。这是一个可重现的数据示例: library(dplyr) library(ggplot2) library(sca
如何去掉 excel 中的前导空格? 我有很多行有这个问题。 最佳答案 在您的空格删除请求中,请注意: TRIM仅删除字符 32,即标准空格。 CLEAN将删除非打印空格,例如回车符(字符 13)和换
当前正在编写指令,并且需要将空格作为字符传递给它。 喜欢: 结果证明 angular 消除了前导空间;但我想保留它。 有什么办法吗? 编辑:我将指令参数作为字符串传递(使用@,而不是作为变量,使用=
我正在为一个使用 Bold for Delphi 对象持久性框架的应用程序的数据库做一些维护。该数据库已经投入生产多年,其中一些表已经变得非常大。其中之一是 BOLD_CLOCKLOG这与 Bold
如何“修剪” NSString 以便仅用旧字符串的特定部分创建新字符串? 例如,我有字符串“Monday the 12th of September”,我如何仅选出“Monday”部分? 最佳答案 使
我是一名优秀的程序员,十分优秀!