【问题标题】:Class "Branches" must implement a "__toString" method to be rendered in a "sfWidgetFormPropelJQueryAutocompleter" widget类“Branches”必须实现“__toString”方法才能在“sfWidgetFormPropelJQueryAutocompleter”小部件中呈现
【发布时间】:2016-07-15 06:13:31
【问题描述】:

我需要什么

  • 我需要在视图中呈现自动完成小部件

部分代码php文件 _work.php

 <!-- Branch -->
  <tr>
    <th>
      <?php echo $form['branch_code']->renderLabel(); ?>
    </th>
    <td>
      <?php echo $form['branch_code']->renderError(); ?>
      <?php echo $form['branch_code']->render(array('size' => '45')); ?>
      <select id="emp_list2" style="display: none;">
        <option></option>
      </select>
      &nbsp
      <a href="#" id="list-all2">[List all]</a>
      <br />
      <?php echo $form['branch_code']->renderHelp(); ?>
    </td>
  </tr>

branches.php

  class Branches extends BaseBranches
  {


   public function __toString()
  {
   return $this->getBranchCode();
   }
    }

错误:

类“Branches”必须实现一个“__toString”方法才能被渲染 在“sfWidgetFormPropelJQueryAutocompleter”小部件中

  • 我已尝试调试此行代码创建错误的问题。
  • 欢迎提出任何建议

【问题讨论】:

  • $this-&gt;getBranchCode() 是否返回字符串?
  • 我已经尝试调试它没有在分支类中渲染,如果将 die 放在工作场所类中它可以工作

标签: php symfony-1.2


【解决方案1】:

只要确保 __toString() 返回一个字符串,那么 $this->getBranchCode() 也应该返回一个字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-13
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多