具有多个元素的 Symfony 表单过滤字段的逻辑
我正在 Symfony 1.4 中实现否定过滤器字段。有 1 个文本输入和 1 个用于否定的复选框。
我可以访问下面的输入值
public function addXXXColumnQuery($query, $field, $value)
{
$v = $value['text'];
$n = 'negation_checkbox_true_or_false'; // don't know how?
if ($n === true)
{
$query->addWhere($query->getRootAlias().'.name = ?', $v);
}
else if ($n === false)
{
$query->addWhere($query->getRootAlias().'.name <> ?', $v);
}
}
,但我不知道如何访问复选框值。
sfWidgetFormInputFileEditable 有一个打印复选框的“with_delete”选项。有人知道检查该值并删除文件的代码在哪里吗?
如果我能找到它,也许我就能弄清楚。
I am implementing a negation filter field in Symfony 1.4. with 1 text input and 1 checkbox for negation.
I can access the input value as below
public function addXXXColumnQuery($query, $field, $value)
{
$v = $value['text'];
$n = 'negation_checkbox_true_or_false'; // don't know how?
if ($n === true)
{
$query->addWhere($query->getRootAlias().'.name = ?', $v);
}
else if ($n === false)
{
$query->addWhere($query->getRootAlias().'.name <> ?', $v);
}
}
but I can't figure out how to access the checkbox value.
sfWidgetFormInputFileEditable has a 'with_delete' option that prints a checkbox. Anyone knows where is the code that checks for that value and delete the file?
If I can find that, maybe I can figure that out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您创建一个
sfWidgetFormInputFileEditable
并将with_delete
选项设置为 true 时,该小部件会呈现一个附加复选框,该复选框以文件上传小部件的名称命名,并带有“_delete”后缀。当复选框被选中时,
sfWebRequest
对象的sfParameterHolder
包含一个以复选框小部件命名的参数。因此,假设您有一个名为“file”的
sfWidgetFormInputFileEditable
。在您的操作中,您可以使用以下命令查看是否选中了删除复选框:When you create a
sfWidgetFormInputFileEditable
with thewith_delete
option set to true, the widget renders an additional checkbox which is named after the file upload widget with a "_delete" suffix.When the checkbox is checked, the
sfParameterHolder
of thesfWebRequest
object contains a parameter named after the checkbox widget.So, suppose you have a
sfWidgetFormInputFileEditable
named "file". In your action, you can see if the delete checkbox is checked using: