0

I have been experimenting with ATK4 for a while now and it's just wonderful!

Migrating to 4.2 I came across a problem with Forms updated and not returning the inserted id.

Here is an example:

class page_kids_new extends Page {
function init() {
    parent::init();

    $this -> add('H1') -> set('New Kid');

    $f = $this -> add('Form');
    $f -> setModel('Kid');
    $f -> addSubmit('Opslaan');

    if ($f -> isSubmitted()) {

        $id = $f -> update();

        $js = $this -> js() -> univ() -> successMessage('Record Saved # ' . $id);

        $js -> execute();
    }

}

}

The data saves nicely in the database (new record).

For some reason it's returning the Form Object. Output to browser is: Record Saved # Object Form(boaadmin_kids_new_form)

Hope someone can help. Thanks in advance.

1 Answers1

0

Probably the behaviour is changed... Need to ask Romans about this! ;) Have you tried $id = $f->get('id'); AFTER the update?

The Elter
  • 235
  • 1
  • 9
  • I remember that was the case with < 4.2, but now $f->get() returns the input from the form in an array. not the result from the database. – Martijn Beurze Apr 26 '12 at 08:14
  • < 4.2 it was unpredictable, it would return ID only for new records. Now $form->update returns $form, but if you need ID then use `$form->update()->model->id` – romaninsh Apr 26 '12 at 08:57