Dynamic get with arrays #474
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#474
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I tried following your youtube video about the dynamic get, but It´s not really walked trough how to use it with the multiple rows type?
I have a table containing the id´s of another table like: '{"0":"2","1":"3","2":"1"}'
I´ve then done a dynamic get with Join View Tables like this:
but in my model for the site view inside this generated function:
public function getJjdelIdJj_delDddb_B($jjdel)
I had to convert the array string into an actual array insted of the json string.
I did it like this:
$array = json_decode($array, true);
before it worked.
Every time i recompile, I have to open the file and insert the above json decoder.
What did I miss for the jcb to do this? :)
And, thank you for such an amazing tool for creating components.
Hmmm, I am not sure I follow. Sounds like you are trying to do something that JCB does not yet support, but with a little bit of custom coding can be done.
I need to see the code to understand more, and then screen shots of all the dynamic view tabs so I can see what you did in JCB an how JCB compiled it.
Hey Jonas, have you considered custom dynamic get? You should have to write the query on your own but the it will also be very flexible in adding more "outside of the box" functionalities.
Peter
Get Outlook for Androidhttps://aka.ms/ghei36
From: eweyn notifications@github.com
Sent: Monday, September 9, 2019 1:05:49 PM
To: vdm-io/Joomla-Component-Builder Joomla-Component-Builder@noreply.github.com
Cc: Subscribed subscribed@noreply.github.com
Subject: Re: [vdm-io/Joomla-Component-Builder] Dynamic get with arrays (#474)
Hmmm, I am not sure I follow. Sounds like you are trying to do something that JCB does not yet support, but with a little bit of custom coding can be done.
I need to see the code to understand more, and then screen shots of all the dynamic view tabs so I can see what you did in JCB an how JCB compiled it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/vdm-io/Joomla-Component-Builder/issues/474?email_source=notifications&email_token=AAVIL6UBAVCKD7PPHJ7C3LLQIYNX3A5CNFSM4IUYJY32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6G7NNA#issuecomment-529397428, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAVIL6TRLP4SV7NMCGR3NE3QIYNX3ANCNFSM4IUYJY3Q.
Thanks!
I got these two admin views
In the "jjpakker" admin view, I got a field to select rows form the jjdele view.
The custom field in "jjpakker" looks like:
In the database the selected rows is stored as the json string mentioned above "'{"0":"2","1":"3","2":"1"}'".
I then have a dynamic get like this in the "joint" tab. I have not edited the other tabs:
And the site view contains this:
That dosen´t work without the decode json I added in the model code.
But with the decode json added, i gives me this on the frontend:
I´m basicly trying to do the same as you do here https://youtu.be/OPuCoxPW35s?t=753 but just with multiple items insted of a single item
After looking a lot at this. This seems to me to be an error.
Has anyone used the IN statement of the dynamic get?
Inside the model for my site view, this function gets generated
public function getJjdelIdJj_delCebc_B($jjdel)
In that function you will find this line:
Which (I guess) works as expected with single row. But with multiple rows:
You got an array that you need to convert to json like:
$array = json_decode($array, true);
instead of the "$array" above in:
// Check if $jjdel is an array with values. $array = $jjdel;
I have never tested it this way, I will try it out and let you know if it is an error or just a wrong setting.
Just to make sure I do this the same way... the
jjdel
field in the maina
table is a custom field (of jjdel table) with multiple selection enabled. So you are trying to return all jjdel rows/items selected in your maina
table inside the custom field calledjjdel
.Well I just tested the above, that I explained. So I think you just have to fix your custom field called
jjdel
since if it is setup correctly the json multi values injjdel
are automatically converted to an array, before passing it to the second function, unless it is not a json.So on my side I do not get the same error/issue, maybe share a screen shot of the whole getItem method.
Thanks for the answer. I will upload screenshots :)
The Dynamic get "JJ pakker"
Custom field JJ del (dynamic)
@Llewellynvdm What data type do you use for the json arrays?
I use
text
most of the time unless I know it will be very small then I usevarchar(265)
.About what I asked for... :
That is the code of a method in the model called
getItem
orgetItems
not the GUI stuff but the code of the actual site-view model. So what you shared does not help me see the code I actually asked for.Thanks @Llewellynvdm!
I made it all work out trying the suggestions here and on the Google forum.
Thank you all for helping med out!
I made it work using a custom get where I did the json_decode inside:
I´m so glad it is working now, I really felt stuck. But with the help from you and Peter, and Jcodewalker and Peter on the google forum, it is now working perfectly.
I really admire your work on JCB, it´s truly a powerful and useful tool. Thanks!