I've got a content type (nodelist) with custom edit form to save some extra information. I created an ajax form element and set a valid callback for it. However it never gets called. Debugging led me to these error:
Notice: Undefined index: nodelist_nodelist_content_type_edit_form in drupal_retrieve_form() (line 737 of /home/lexor/www/myproject/includes/form.inc).
and as a result
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'nodelist_nodelist_content_type_edit_form' not found or invalid function name in drupal_retrieve_form() (line 772 of /home/lexor/www/myproject/includes/form.inc).
Deeper investigations show that
function_exists($form_id) in form.inc's drupal_retrieve_form returns false
since the .inc file of my content type hasn't been included yet at this stage, and I've got no idea on
how to do that... Anyway, it looks like a bug.
Comment | File | Size | Author |
---|---|---|---|
#39 | ctools-entity_field_formatter_ajax-1259430-39.patch | 9.81 KB | ron_s |
#15 | interdiff-14-15.txt | 4.4 KB | das-peter |
#14 | entity_field-formatter-ajax-1259430-11.patch | 6.69 KB | Hydra |
#11 | 1259430-entity_field-formatter-ajax.patch | 6.9 KB | dawehner |
#10 | issue_1259430_panels_3.0_alpha3.patch | 1.14 KB | oxrc |
Comments
Comment #1
dawehnerSubscribe
I fear the panels ui is not compatible with the default ajax callback.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commenteddereine is correct. #ajax makes too many assumptions about the form to be used in Panels forms at this time.
For example, that the form callback will always be available. :(
Comment #3
dawehnerMove to ctools as the fix is there.
Sadly the configuration is not stored at the moment. Any kind of idea why would be actually really great!
Comment #4
dawehnerTo easy reproduce the issue just add a body field and choose trimmed as formatter and use another formatter.
Not even the formatter is stored so i'm a bit confused.
Comment #5
dawehnerNo idea whether this is elegant or not but this two patches works for me.
/me bets there are millions of dsm's left.
Comment #6
dawehnerSome less dd() calls maybe some rewrite of the fields integration could be removed again.
Comment #7
dawehnerHere is the newest version.
Manuall testing of the field-field worked fine.
PS: We need a easy way to remove many fields, like on views :)
Comment #8
dawehnerHere is a new version for ctools.
Comment #9
Iwarold CreditAttribution: Iwarold commentedHello,
Got the same issue with Form API Ajax & Ctools (using a custom form in a custom ctools content type. The custom form isn't foundable as it's defined in content type file which is not included). Is there any news on this task since September ? May I assume applying these patches is enough to fix it ?
Comment #10
oxrc CreditAttribution: oxrc commentedI have patched against panels-3.0-alpha3 (need it for a site currently on developing stage), because the latest dev version of panels did not include the changes described there.
Comment #11
dawehnerSo only #10 was required but it's part of panels now.
Here is a patch
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedComment #13
Hydra CreditAttribution: Hydra commentedI rerolled the patch, it should apply against the actual git (7.x-1.x ) branch. Would be awesome to get this commited!
Comment #14
Hydra CreditAttribution: Hydra commentedI should attach it as well :P
Comment #15
das-peter CreditAttribution: das-peter commentedEverything seems to work functionality wise.
Tested with a vanilla installation as well as existing ones - some of them with quite complex formatters (media & slideshow stuff).
However, I've found some coding standard violations in the code touched by the patch.
I've adjusted that - please check interdiff to see the changes.
Comment #17
das-peter CreditAttribution: das-peter commentedLooks like something went wrong. Let's try again.
Comment #18
das-peter CreditAttribution: das-peter commentedI'm about to re-factor a bigger site (thus there's this issue too: #2011814: Add a JS quick filter to the add content modal dialog ;) ) - I'll apply the latest patch and will do extensive manual testing that way.
Comment #19
das-peter CreditAttribution: das-peter commentedWhile working with the patch applied I came across some issues.
The values/fields defined by
ctools_content_configure_form_defaults()
weren't stored if the formatter was changed.Reason was, that
ctools_content_configure_form_defaults_submit()
wasn't called by the ajax request.The attached patch fixes that.
However, if someone knows of a more generic way to solve this hints would be very welcome :)
Comment #20
Hydra CreditAttribution: Hydra commentedSeems reasonable to me. Thanks for working on this! For me this loos RTBC, would be very nice to see this committed :)
Comment #20.0
Hydra CreditAttribution: Hydra commentedUp
Comment #22
das-peter CreditAttribution: das-peter commentedRe-roll and fix for default formatter settings.
Comment #23
sahaj CreditAttribution: sahaj commentedCoud the patch be commit or something is preventing it?
Comment #24
podarokPlease, do use here "early return" pattern?
Comment #25
das-peter CreditAttribution: das-peter commented@podarok What would be the gain of that, and should we really adjust the architecture here? That's somehow an unrelated change as far as I can see atm. And it's already taking long to get this in without "unrelated" changes ;)
Comment #26
podarokYou were asking for review. I did that.
If You do not want to get this commited, just ignore my review, who need that... (((
http://pear.php.net/manual/en/standards.bestpractices.php
@merlinofchaos, If You are good with this spaghetti code, please, do commit it.
Comment #27
das-peter CreditAttribution: das-peter commented@podarok Hey, easy there. What's wrong with asking what the benefit of something is? This wasn't any-kind of attack towards you. The issue queue is a place to discuss erm well issues and that's all I wanted to do. If my response looked like an attack to you, I sincerely apologize.
And of course reviews are highly appreciated, but that doesn't mean one isn't allowed to ask questions about a feedback.
Now back on the technical / administrative topic:
ctools_entity_field_content_type_formatter_options_submit
(as far as I understand) has 22 lines and 2 nestedforeach
loops (9 lines in total). For me this is far from unreadable and very well maintainable without adding further flow controls to enhance (if even) the readability.In the current case I'm in doubt that it makes sense because it's such a small piece of code. However, I guess this is a topic we could discus days and may would have to agree that we disagree :)
So based on that I asked "What would be the gain of that..."
Finally I think all the information needed is available, still reviews needed & very welcome - but be warned there might be questions related to incoming feedback :) That said, back to "Needs review".
Comment #30
das-peter CreditAttribution: das-peter commentedRe-rolled
Comment #31
discipolo CreditAttribution: discipolo commentedrerolled against current dev
Comment #32
ron_s CreditAttribution: ron_s commentedHave been using #31 for a while and does the job for us.
Comment #33
rivimeyHey ron, thanks for the info! It's really helpful to know when things work.
Comment #34
rivimeyJust checked and the patch applies cleanly to current ctools 7.x-1.x-dev.
There's some good work in the function-docs and the code seems to be sane on a quick read-through, though I've done no detailed checks.
@das-peter, @ron_s: It would be really helpful if there were some additional 'simpletest' tests for this area... even something small to get started with.
Comment #35
japerryUgh. This -looks- ok to me, but it is a lot of code. Perhaps we can get a test to help confirm its working?
Comment #36
DamienMcKennaComment #37
rivimeyComment #38
DamienMcKennaThis didn't get into 1.13, maybe it will get into 1.14.
We need to try getting this to RTBC.
Comment #39
ron_s CreditAttribution: ron_s commentedThere was a change to the
ctools_fields_get_field_formatter_settings_form
function in 1.13 that causes this patch to break.The difference between #31 and #39 is the function no longer has
if
conditionals around it (this has been removed: https://cgit.drupalcode.org/ctools/tree/includes/fields.inc?id=2047a9b91...), so theif (!empty($form_key)) {
patch code isn't referenced correctly.New version available for review, see attached.
Comment #41
MustangGB CreditAttribution: MustangGB commentedComment #42
ron_s CreditAttribution: ron_s commentedPatch #39 still applies cleanly to the new CTools 7.x-1.14.
Anyone available to test so we can possibly get into the next release?
Comment #43
DamienMcKennaComment #44
ron_s CreditAttribution: ron_s commentedStill applies cleanly to 7.x-1.15...
Comment #45
rivimeyComment #46
joelpittetComment #47
joelpittetI agree with @jperry, #35 needs tests, I don't feel confident committing this without them.
Comment #48
joelpittetComment #49
ron_s CreditAttribution: ron_s commentedWe've been using patch #39 for the past 2.5 years with no issues, but I understand if tests are preferred. Unfortunately I don't have availability at the moment to do so.
Comment #50
joelpittet