atk4 / mastercrud

Manipulates ATK CRUD through the force of references
https://atk4.org
MIT License
9 stars 7 forks source link

Allow to specify custom CRUD relations? #20

Open rapgithub opened 5 years ago

rapgithub commented 5 years ago

Is it possible to mantain the relation between tables that are in relation?

Cities -> has many themes, and each themes -> has many hotels

I will like CRUD shows not only that cities has many themes

but I want to be able to click on the theme name once it is created and when clicked takes me to the Hotels list...

I tried to create a relation like that with CRUD but I get this error:

atk4\ui\Exception: Unable to set property for the object

Any way to do this ?

my code:


$crud = $app->add([
    '\atk4\mastercrud\MasterCRUD',
    'quickSearch'=>['city'],
    'ipp'=>5,
    'fieldsRead'=>['city']
]);

$m = $crud->setModel(new Cities($app->db),
[
  'Themes'=>[
    'CRUD', 'quickSearch'=>false, 'canDelete'=>true, 'canUpdate'=>true',
    'Hotels'=>[
      'CRUD', 'quickSearch'=>false, 'canDelete'=>true, 'canUpdate'=>true'
    ]
  ], 
]);

any ideas?

thanks

DarkSide666 commented 5 years ago

With latest changes in MasterCrud you should be able to do like this. See _crud key - that's how you can pass properties to sub-cruds.

There is also key _tabs. That's how you can pass some properties to tabs view if needed.

$crud = $app->add([
    '\atk4\mastercrud\MasterCRUD',
]);

$m = $crud->setModel(new Cities($app->db),
[
    '_crud' => ['quickSearch'=>['city'], 'ipp'=>5, 'fieldsRead'=>['city']], // for Cities
    'Themes'=>[
        '_crud' => ['quickSearch'=>false, 'canDelete'=>true, 'canUpdate'=>true], // for Themes
        'Hotels'=>[
            '_crud' => ['quickSearch'=>false, 'canDelete'=>true, 'canUpdate'=>true], // for Hotels
        ]
    ], 
]);

Please check if this works for you and if it does (or doesn't not) let us know by replying here.

rapgithub commented 5 years ago

thanks I will check it sorry I miss this message I do not know why I did it see it before :)