Hi guys,
I added Views support to the to_do project and it generally works great.
Today I added support for buttons to be included in your view. The field works, except when I click on the Rearrange button (up/down arrows in the Fields box.)
What's happening is that the field is totally ignored and thus not included in the list of fields to move up and down. The problem is not just that I cannot sort the list, it's also that the buttons field is removed at the time I hit Save.
Although that's a 3rd party module, I would think that the problem is likely in the Views handling. I tried several things and it has not helped. All the other to_do fields work great, so I don't see why this one would break.
The one thing that's different from the other fields is that this one has a different database field name than its view name (i.e. 'to_do_button' in the views array versus 'to_do.priority' in the database.)
Thank you.
Alexis
Comments
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedFixed the title. Just to complement, I tried to add the options functions in the class, and it made no difference...
Comment #2
dawehnerIt would be cool if you could commit the non-working field or paste your code here.
Comment #3
AlexisWilke CreditAttribution: AlexisWilke commentedDereine,
It is in the to_do project (the 6.x-1.x-dev version).
I would think that just that specific entry would not help as much because you probably will need all the environment of the to_do project to test...
The class itself is very simple:
It derives from this one:
Declared in two arrays as usual. The handlers:
And the views data:
Comment #4
dawehner'field' => 'priority',
This should be "real field" i think.
Comment #5
AlexisWilke CreditAttribution: AlexisWilke commentedDereine,
No luck.
I found a view example and it looks like the 'real field' needs to be defined right outside of the 'field' array. So I did it that way and it still does not work...
Thank you.
Alexis
Comment #6
Letharion CreditAttribution: Letharion commented@AlexisWilke
I see you've gotten out a new version after this issue was touched. Have you worked this out, or do you still need help?
Comment #7
AlexisWilke CreditAttribution: AlexisWilke commented@letharion,
Nope... Not fixed yet. I tried with your latest changes (Nov 8) and it still breaks.
You may want to give it a try. Install To do, create like 3 entries with random data, then create a view with To do nodes. In the fields, enter say Node title, To Do Buttons, Node Body. See that the previous shows you what you'd expect, then click on the up/down arrows of the fields. To Do Buttons does not appear!
Thank you.
Alexis
Comment #8
Letharion CreditAttribution: Letharion commentedI can reproduce the problem, but don't know what's wrong.
I'll see if I can figure something out later.
Comment #9
Letharion CreditAttribution: Letharion commentedThe problem is that the re-arrange part of the UI assumes that it gets text. The #type of the buttons gets set to "textfield", which breaks.
I don't think it makes sense to support buttons in the re-arrange UI, but a solution would be to pull the label from the button, prefix it with "Button: " or something similar, and display that.
@merlinofchaos
Please comment on how you suggest we solve this, and I'll try to come up with a patch :)
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedThe problem is the field id 'buttons'. Views places all fields on the form in $form[$id].
However, Views places all buttons on the form in $form['buttons']. So on the rearrange form, this data ends up overridden by buttons.
That means 'buttons', along with things like 'override', 'form_id', 'form_token' and 'form_build_id' are not going to work here. We probably just need to move everything from the top level of form into $form['fields'].
A work around is to change the id to something other than buttons, and your code will work.
Since we don't want to make those IDs invalid, here is a patch for the issue against 2.x -- could use some testing to make sure I didn't screw anything up but it seems to work ok.
Comment #11
AlexisWilke CreditAttribution: AlexisWilke commentedI "applied" (by hand) your patch to 3.x since that's what I'm running with now and it worked!
I cannot test 2.x though since I do not have it anywhere.
Thank you.
Alexis
P.S. WARNING: This patch actually loses all the fields on a Save. I guess I only tested the click to see the window and Cancel button without trying to save the result. The fact is that right now this patch loses all the fields. More later...
Comment #12
AlexisWilke CreditAttribution: AlexisWilke commentedOkay, I got a fix to my patch in #11. I simply don't change the submit() function. Now I thought that using the #tree would force the system to keep the tree, but it did not... In any event, by not changing the function it was perfectly.
Thank you!
Alexis Wilke
Comment #13
AlexisWilke CreditAttribution: AlexisWilke commentedAnd just in case, there is a new patch without that last hunk. Thanks.
Comment #14
AlexisWilke CreditAttribution: AlexisWilke commentedComment #15
iamjon CreditAttribution: iamjon commentedI tested merlinofchaos' patch on 2x and I'm quite sure it didn't work.
I go an error upon installing views with the patch (it could be unrelated, attached)
I generated a bunch of todos via devel generate. Made a view from AlexisWilke screenshot and had the button field dissapeared.
AlexisWilke cool module btw.
Comment #16
iamjon CreditAttribution: iamjon commentedi think it's not working in 3x too.
Comment #17
iamjon CreditAttribution: iamjon commentedWho would have figured that you have to actually apply the patch instead of creating a new one.
Anyway, it works for both as advertised
Comment #18
AlexisWilke CreditAttribution: AlexisWilke commentedI suppose you mean #13 works for you? 8-)
I have a problem with the v3.x patch at this point. Actually, the whole rearrange fields interface is not working right for me. So I was waiting for an update to see whether it would get fixed.
Anyway, once you confirm that #13 works for you, then I'll check it in.
Thank you.
Alexis
Comment #19
iamjon CreditAttribution: iamjon commentedYea, both 13 and #10 work for me
Comment #20
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to 6.x-2.x and 6.x-3.x -- doesn't apply to 7.x.
Comment #21
dawehnerPorted to d7 and played a bit with it.