error on update block

Permalink
Well, I have made a block for projects. When I add a project and some images within it, and I save, the update goes fine. But when I refresh the page and edit the block, the block inserts an new bID... Even when I made an input field for bID (which shows the right bID), the block wil add the project in stead of updating. In the example (attached) the bID = 64. But the bID on the submit button says bID is 65. What is going wrong? How can I solve this problem?

Below the controlleer.php

class ProjectenBlockController extends BlockController {
   protected $btName = 'Projecten';
   protected $btDescription = 'Plaats een nieuw project';
   protected $btTable = 'btProjecten';
   protected $btInterfaceWidth = "450";
   protected $btInterfaceHeight = "450";
   protected $btCacheBlockRecord = true;
   protected $btCacheBlockOutput = true;
   protected $btCacheBlockOutputOnPost = true;
   protected $btCacheBlockOutputForRegisteredUsers = true;
   protected $btCacheBlockOutputLifetime = 300;
   public function view() {
      $this->set('bID',$this->bID);
        $this->set('pNaam',$this->pNaam);
      $this->set('pAdres',$this->pAdres);

1 Attachment

henkvanhoffen
 
A3020 replied on at Permalink Reply
A3020
Hi Henk, goedemorgen,

You shouldn't use the bID as an identifier for a project. It gets incremented each time you modify a block.
Instead, use an extra field like projectID or something in your db.xml. You can add an extra input field (hidden if you want) to the edit.php or form.php with the projectID as a value. Use that input field as an identifier to refer to a certain project.

Groeten, Adri
henkvanhoffen replied on at Permalink Reply
henkvanhoffen
Hi Adri,

Thanks for your reply. You are absolutely right! I thought this bID was an unique id for the Block... But yes, I see my mistake! Your solution will solve my problem!

Groet, Henk