Problem with ActiveRecord's function save()

I try insert data in a mysql database but I can’t. I try but always show the next error

Integrity constraint violation – yii\db\IntegrityException

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘0’ for key ‘PRIMARY’

The SQL being executed was: INSERT INTO sucursal (id_sucursal) VALUES (DEFAULT)

Error Info: Array

(

[0] => 23000


[1] => 1062


[2] => Duplicate entry '0' for key 'PRIMARY'

)

Caused by: PDOException

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘0’ for key ‘PRIMARY’

I do a form where get the id_sucursal and the codigo but the error show that the sentence is

“INSERT INTO sucursal (id_sucursal) VALUES (DEFAULT)” but this sentence shouldn’t execute. The controller get well the post data from form and the model too.

I can’t set id_sucursal AUTO_INCREMENT.

this is the model, controller and form model.

pastebin.com/TCErfnnG

Do check the DB schema again.If possible paste table structure here

You can even try this:

(say)

$model->save(false);

Set auto increment to your primary key…