当我检查页面时,Switch小部件不工作,我得到以下错误。“无法将类WhSwitch的对象转换为字符串”
我怎样才能让它对我的脚本起作用呢?
<?php $this->widget('bootstrap.widgets.TbTabs', array(
'placement' => '',
'tabs' => array(
array('label' => Yii::t('strings', 'Settings'), 'content' => '
<article class="settings-tab">
<span class="settings-table">
<table>
<tr>
<td>Deadline of payment</td>
<td><input type="text" class="form-control deadline-input" placeholder="14"></td>
</tr>
<tr>
<td>Link dropbox</td>
<td>
'.$this->widget('yiiwheels.widgets.switch.WhSwitch', array('name' => 'switchbuttontest')).'
</td>
</tr>
<tr>
<td>Save to dropbox</td>
</tr>
<tr>
<td>Mail copy of invoice</td>
</tr>
<tr>
<td>Get email when invoice is paid</td>
</tr>
<tr>
<td>Allow partial payments</td>
</tr>
</table>
</span>
</article>
', 'active' => true),发布于 2014-03-13 17:47:28
尝试一下,首先将小部件保存在变量中,如下所示
$yourwidget=$this->widget('yiiwheels.widgets.switch.WhSwitch',
array('name' => 'switchbuttontest'));现在,在您的tbTabs小部件中放置encodeLabel=>false,如下所示
<?php $this->widget('bootstrap.widgets.TbTabs', array(
'placement' => '',
'encodeLabel'=>false,
//your tabs然后像这样使用它
<td>
.$yourwidget.
</td>编辑:如果上面的代码不工作,那么有更优雅的解决方案。
创建一个视图文件,并将整个代码(您希望显示在选项卡下)放在该视图中file.In该文件中,您可以轻松地将小部件嵌入到元素之间,而无需使用引号。然后你可以像下面这样使用它
array('label' =>Yii::t('strings', 'Settings'),
'content' => $this->renderPartial('pages/_form_basic', true), 'active' => true), 发布于 2014-03-14 20:46:04
修好了!
解决方案:
从'.$this->widget('yiiwheels.widgets.switch.WhSwitch',数组(‘name’=>‘switchbuttontest’))‘
到这个
'.$this->widget('yiiwheels.widgets.switch.WhSwitch',数组(‘name’=> 'switchbuttontest'),true)‘
https://stackoverflow.com/questions/22373733
复制相似问题