I need help in ATK4 CRUD. I have built a backend for a project using Agile Toolkit 4.1.3.
I have the following Model:
class Model_Product extends Model_Table
{
public $entity_code = 'product';
function init()
{
parent::init();
$this->addField('category_id')->refModel('Model_Category')->mandatory(true);
$this->addField('name')->mandatory(true);
$this->addField('picture_id')->refModel('Model_Picture')->mandatory(true);
$this->addField('short_description')->mandatory(true);
$this->addField('description')->type('text')->mandatory(true);
$this->addField('uploaded_at')->type('datetime');
$this->addField('price')->type('int')->mandatory(true);
$this->addField('quantity')->type('int')->mandatory(true);
$this->addField('status')->datatype('list')
->listData(array(
'enabled'=>'Enabled',
'disabled'=>'Disabled',
))
->defaultValue('enabled');
}
}
the page:
<?php
class page_index extends Page {
function init(){
parent::init();
$page=$this;
$tabs = $page->add('Tabs');
$tabs->addTab('Product')->add('CRUD')->setModel('Product');
....
On my localhost all CRUD functions work flawlessly, but after I uploaded the files to the webserver when I try to add a new product I get this error:
`Error in AJAX response: SyntaxError: invalid XML attribute value
SQLException
Could not execute query: insert into product (category_id, name, picture_id, short_description, description, uploaded_at, price, quantity, status) values (NULL, ‘as’, NULL, ”, ”, NULL, 2500, 25, ‘enabled’)
Last query:
insert into product (category_id, name, picture_id, short_description, description, uploaded_at, price, quantity, status) values (NULL, ‘as’, NULL, ”, ”, NULL, 2500, 25, ‘enabled’)
MySQL error:
Column ‘category_id’ cannot be null`
Strange thing that the missing values in the query are visible in the crud form but never make it to the query. Additional info: in Model_Picture I use varchar id field instead of autoincrement int but once again everything works fine on localhost.
Thanks!
I had all my crud functions on one page on tabs like this:
Then I created a new page for every Model and added only one CRUD on each page and it solved the problem, now it works fine both on localhost and the server.
Thank you guys for all your help.