what i need

  • i need to render autocomplete widget in view

partial code php file _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();
   }
    }

error:

Class "Branches" must implement a "__toString" method to be rendered in a "sfWidgetFormPropelJQueryAutocompleter" widget

  • i have tried to debug issue this piece of line code create error.
  • any suggestion is most welcome
1

There are 1 best solutions below

0
M.R. On

Just make sure that __toString() is returning a string, so $this->getBranchCode() should return a string as well.