When a form field is empty but should contain an "integer" value in the database some engines will try to insert an empty string into an integer field.
This is what causes the error message, basically trying to put the square through the round hole.
If you implement the Nullable trait you can make sure that these fields, if left empty are inserted as a true NULL
instead of a string
I prefer to have my trait as a use statement above the class and then a short use int the class itself.
You can also put it directly in the class by use \October\Rain\Database\Traits\Nullable;
instead of use Nullable;
if you don't wish to have it appear in two spots. It's up to your preference.
use Model;
use October\Rain\Database\Traits\Nullable;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/**
* Page Model
*/
class ModuleLink extends Model
{
public $table = 'your_table_name_here';
use Nullable; // This sets the trait to be used in this Model.
//^^^^^^^^^^^^^
public $nullable = [
'module_id', // Define which fields should be inserted as NULL when empty
'sort_order',
];