带有属性提交的 Yii 按钮 - 不起作用
昨天它正在工作。经过多次更改(但不是使用模板) - 事实并非如此。 Yii 像往常一样生成按钮,但现在单击它不会执行任何操作。
<?= CHtml::button('Sell', array(
'submit' => CController::createUrl('product/selll', array('productID' => $data->id)),
'style' => 'width:80px',
)); ?>
也许我发现了问题 - 这是因为 jquery.yiiactiveform.js 没有自动加载。为什么不再加载了?
我已经找到解决方案。问题是上面的 Yii 表单,我有评论输入文本字段,但没有一个 Yii::button 工作。 这是上面形式的代码:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'searform',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'action' => array("user/searchForm"),
));?>
!!!!If i comment this textField - no one CHtml::button dont work.!!!!!
<?php echo $form->textField($search,
'product',array('width'=>'179px','height'=>'17px','value'=>$value,'save'=>$value)); ?>
<? /*
<div id="srcBtnWrap">
<?= CHtml::submitButton('',array('id'=>'srcBtn')); ?>
</div> */ ?>
<? //= CHtml::submitButton('go'); ?>
<?
$this->endWidget();
?>
是 Yii bug,还是我做错了什么?
Yesterday it was working. After many changes (but not with it template) - it's not.
Yii generates button as usually, but now by clicking it does nothing.
<?= CHtml::button('Sell', array(
'submit' => CController::createUrl('product/selll', array('productID' => $data->id)),
'style' => 'width:80px',
)); ?>
Maybe i have found the problem - it is because jquery.yiiactiveform.js is not loading automaticly. Why it's not loading any more?
I have found solution. The problem is Yii form above, i've comment input text field, than no one Yii::button is working at all.
This is a code of form above:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'searform',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'action' => array("user/searchForm"),
));?>
!!!!If i comment this textField - no one CHtml::button dont work.!!!!!
<?php echo $form->textField($search,
'product',array('width'=>'179px','height'=>'17px','value'=>$value,'save'=>$value)); ?>
<? /*
<div id="srcBtnWrap">
<?= CHtml::submitButton('',array('id'=>'srcBtn')); ?>
</div> */ ?>
<? //= CHtml::submitButton('go'); ?>
<?
$this->endWidget();
?>
Is it Yii bug, or i do something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jquery.yii.js 应该被加载。如果已加载 - 检查 JS 控制台是否有错误。
检查您的操作是否未使用 die() 或 exit()
jquery.yii.js should be loaded. If it is loaded - check JS console for errors.
Check if your action does not use die() or exit()
您已启用客户端验证。请检查错误并向我们提供模型字段(规则)
You have enabled client validation. Please, check errors and give us model fields (rules)