Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DropDown and Lookup in connection with hasOne is not working in CRUD anymore #1462

Closed
karakal opened this issue Sep 29, 2020 · 13 comments
Closed

Comments

@karakal
Copy link
Contributor

karakal commented Sep 29, 2020

In the newest code in develop (which I need to use...) DropDown and Lookup in a model will not be filled anymore.

I have multiple models with hasOne and in the table everything is fine, but when I try to edit an element, the dropdown or lookup will always return "No results found".

This error is even in the demo visible at https://ui.agiletoolkit.org/demos/collection/actions.php when you try to edit an element, that has a parent-folder set:
grafik

When you set the model explicit to the dropdown everything is working fine.

@ibelar
Copy link
Contributor

ibelar commented Oct 5, 2020

@karakal - Can you share code on how you defined your model? All seems to be working fine. I think the demo is fine too because hasOne only returns one parent only. @DarkSide666 - can you confirm about file demo data?

@karakal
Copy link
Contributor Author

karakal commented Oct 6, 2020

@ibelar
All of my hasOne are defined as follows:
$this->hasOne('Unit', [ 'model' => '<path>\Unit', 'our_field' => 'unit_id', 'their_field' => 'id', 'caption' => 'Unit', 'required' => true ])->withTitle();

This works out as correctly displayed in the overview:
grafik

and it will display correctly the selected entry:
grafik

But it displays "No result found":
grafik

although there should be a selection of them:
grafik

And I don't think the demo is right, because there should be a selection of a lot of root folders...

@mkrecek234
Copy link
Contributor

mkrecek234 commented Oct 6, 2020

Hi @karakal I had similar strange effects with dropdowns not working - just because the installed PHP version was too old. Upgrade to 7.3 or 7.4 and some mysterious effects might be gone immediately.

@DarkSide666
Copy link
Member

There surely is some issue (or issues) here with hasOne and dropdowns.
Also model addTitle() added expression field don't load values. Maybe that's because of that.

Will work more on that tomorrow #1477

@DarkSide666
Copy link
Member

I think it's fixed now.

@karakal
Copy link
Contributor Author

karakal commented Nov 12, 2020

I just installed the freshest version (2.3.1) and it definitely doesn't work:
grafik

My definition (that worked in former times) was:
$this->hasOne('LineColour', [ 'model' => 'marbach\connectm\admin\Colour', 'our_field' => 'colour_id', 'their_field' => 'id', 'caption' => 'Farbe', ]);

I tried this definition
$this->hasOne('colour_id',[new Colour()])->addTitle();

But it's not working....

@karakal
Copy link
Contributor Author

karakal commented Nov 12, 2020

Okay... It is working in the latest development-Branch from Github :-(
could you do a release anytime soon?

@DarkSide666
Copy link
Member

DarkSide666 commented Nov 16, 2020

@karakal Can you try installing 2.3 like this and tell us if it works then ?

    "atk4/ui": "dev-release/2.3 as 2.3.2",

@mvorisek
Copy link
Member

closing as resolved

@mhuser
Copy link
Contributor

mhuser commented Dec 2, 2020

Hi,
I just stepped on this issue while experimenting the same problem (model with hasOne and "no results")
With the fix, I now see all results...
But filtering the lookup like in
$form1->getControl('timesheet_project_id')->model->addCondition('user_id', $app->user->getId());
Doesn't seems to works anymore and adding condition in dependency neither.
Should it?

@mvorisek
Copy link
Member

mvorisek commented Dec 2, 2020

please submit a failing test case as PR

@mhuser
Copy link
Contributor

mhuser commented Dec 3, 2020

@mvorisek thank you for your quick answer. I have forked and branched develop, time to brew coffee and I will give it a try.

@mhuser
Copy link
Contributor

mhuser commented Dec 3, 2020

I added a segment in demo lookup-dep in #1556.
Seems addCondition at initialization is working, but not if called on lookup->model after.
Not sure how I could turn this code into a true test case. I think I should check in the test if the lookup return a certain array but I cannot see how to manage that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants