original_string: public function toggleField(Table $table, $id, $value, $field = 'status')
      {
          $this->checkIsAjax();
          $this->_checkToggleData($id, $value);
  
          $this->_controller->viewBuilder()
              ->setLayout('ajax')
              ->setTemplate('toggle')
              ->setTemplatePath('Common');
  
          $entity = $table->get($id);
          $entity->set($field, !(int) $value);
  
          if ($result = $table->save($entity)) {
              $this->_controller->set('entity', $result);
              $this->_controller->render('toggle');
          } else {
              throw new \RuntimeException(__d('core', 'Failed toggling field {0} to {1}', $field, $entity->get($field)));
          }
      }
code: public function toggleField(Table $table, $id, $value, $field = 'status')
      {
          $this->checkIsAjax();
          $this->_checkToggleData($id, $value);
  
          $this->_controller->viewBuilder()
              ->setLayout('ajax')
              ->setTemplate('toggle')
              ->setTemplatePath('Common');
  
          $entity = $table->get($id);
          $entity->set($field, !(int) $value);
  
          if ($result = $table->save($entity)) {
              $this->_controller->set('entity', $result);
              $this->_controller->render('toggle');
          } else {
              throw new \RuntimeException(__d('core', 'Failed toggling field {0} to {1}', $field, $entity->get($field)));
          }
      }
code_tokens: public function toggleField ( Table $ table , $ id , $ value , $ field = 'status' ) { $ this -> checkIsAjax ( ) ; $ this -> _checkToggleData ( $ id , $ value ) ; $ this -> _controller -> viewBuilder ( ) -> setLayout ( 'ajax' ) -> setTemplate ( 'toggle' ) -> setTemplatePath ( 'Common' ) ; $ entity = $ table -> get ( $ id ) ; $ entity -> set ( $ field , ! ( int ) $ value ) ; if ( $ result = $ table -> save ( $ entity ) ) { $ this -> _controller -> set ( 'entity' , $ result ) ; $ this -> _controller -> render ( 'toggle' ) ; } else { throw new \ RuntimeException ( __d ( 'core' , 'Failed toggling field {0} to {1}' , $ field , $ entity -> get ( $ field ) ) ) ; } }
docstring: Toggle table field value.
  
  @param   Table $table
  @param   int $id
  @param   string|int $value
  @param   string $field
  
  @throws  \RuntimeException
  @throws  \Aura\Intl\Exception
docstring_tokens: Toggle table field value .