[21:50:38] | <symbioquine[m]> | > It just threw an error for . and .. |
[21:50:38] | <symbioquine[m]> | Careful 😲 |
[10:00:39] | <skipper_is[m]> | I'm trying to add a callback to a checkbox for a quick form in 1.x |
[10:00:55] | <skipper_is[m]> | '#ajax'=>array( |
[10:00:56] | <skipper_is[m]> | 'callback'=>'farm_quick_machinery_quick_form_faults_ajax', |
[10:00:56] | <skipper_is[m]> | 'wapper'=>'quick_machinery-faults' |
[10:01:00] | <skipper_is[m]> | So far I've got that |
[10:01:12] | <skipper_is[m]> | ACTION < https://libera.ems.host/_matrix/media/r0/download/libera.chat/9d7155ac1f... > |
[10:01:47] | <skipper_is[m]> | Which is refering to a form container called `['quick_machinery']['fault']` |
[10:02:05] | <skipper_is[m]> | But nothing is happening..... |
[10:02:40] | <skipper_is[m]> | ACTION < https://libera.ems.host/_matrix/media/r0/download/libera.chat/bdf88ee2e5... > |
[10:02:55] | <skipper_is[m]> | Which ...should.... fire if the box is checked (or not), check if it is checked, and display, or not |
[10:03:11] | <mstenta[m]> | Hmm - so nothing happens when you click the checkbox you mean? Any requests made in the Network tab of devtools? |
[10:03:18] | <skipper_is[m]> | Nothing visible |
[10:03:34] | <skipper_is[m]> | I sometimes put a print_r("hello world"); after the if statement to check |
[10:03:43] | <skipper_is[m]> | and it just throws an error if the box is checked |
[10:03:45] | <mstenta[m]> | I have a veeeery vague memory... about ajax not working on checkboxes or something... this feels very familiar |
[10:04:05] | <skipper_is[m]> | I was looking at the quick planting as an example |
[10:04:09] | <skipper_is[m]> | but that uses checkboxes |
[10:04:12] | <mstenta[m]> | oh ok |
[10:04:12] | <skipper_is[m]> | rather than single checkbox |
[10:04:17] | <mstenta[m]> | ah |
[10:04:24] | <mstenta[m]> | hmm yea that sounds familiar too :-) |
[10:04:43] | <mstenta[m]> | https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen... |
[10:05:00] | <mstenta[m]> | ^ it does say that `#ajax` can be applied to both `checkbox` and `checkboxes` types... |
[10:05:09] | <mstenta[m]> | so maybe i'm misremembering |
[10:05:24] | <skipper_is[m]> | It is doing something, I can replace the whole form block with just print_r($form_state['values']['faultcheck']); to just print off the value of the checkbox |
[10:05:27] | <mstenta[m]> | do you have xdebug set up by any chance? |
[10:05:34] | <skipper_is[m]> | I do no |
[10:05:37] | <skipper_is[m]> | *not |
[10:05:58] | <skipper_is[m]> | When I replace it with print it just throws error 200, but the error status text is my printed value |
[10:06:14] | <mstenta[m]> | ajax is much easier to debug with a debugger... it can be quite frustrating otherwise haha |
[10:07:05] | <mstenta[m]> | could you put your whole file in pastebin? |
[10:07:19] | <mstenta[m]> | i can give it a quick skim to see if anything jumps out at me |
[10:07:29] | <skipper_is[m]> | I can indeed, currently it is just the form structure, no validation or anything |
[10:07:50] | <mstenta[m]> | cool cool that should be all i need |
[10:08:06] | <skipper_is[m]> | https://pastebin.com/KeG3Uf1n |
[10:09:31] | <skipper_is[m]> | I keep thinking have I put an extra s somewhere... or typo... |
[10:09:46] | <mstenta[m]> | that's the first thing i'm double checking :-) |
[10:09:57] | <mstenta[m]> | that's the most common mistake i make |
[10:10:15] | <skipper_is[m]> | Ditto, although usually it is severe enough to throw a 500 |
[10:10:21] | <mstenta[m]> | this looks generally correct |
[10:10:35] | <mstenta[m]> | one thing that might be worth double checking is `if (!empty($form_state['values']['faultcheck'])){` |
[10:10:49] | <mstenta[m]> | maybe print that var |
[10:10:55] | <mstenta[m]> | and see if it's what you're expecting |
[10:11:42] | <mstenta[m]> | > I sometimes put a print_r("hello world"); after the if statement to check |
[10:11:42] | <mstenta[m]> | > and it just throws an error if the box is checked |
[10:11:42] | <mstenta[m]> | what error? |
[10:13:12] | <skipper_is[m]> | That one |
[10:13:13] | <skipper_is[m]> | ACTION uploaded an image: (78KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/OSbvdVQsZij... > |
[10:13:37] | <skipper_is[m]> | The 1 at the beginning correlates to the value of the checkbox though, if its unticked, it's 0 |
[10:13:41] | <mstenta[m]> | another thing i'd try is: change the `checkbox` to a `select` with `#options => array(0 => t('No'), 1 => t('Yes'))` - and just see if *that* works (to isolate whether or not `checkbox` is an issue |
[10:14:00] | <mstenta[m]> | i really feel like i've run into something like this before with `checkbox`... |
[10:14:23] | <skipper_is[m]> | Hmm, ok I'll give that a spin up |
[10:14:27] | <mstenta[m]> | ok yea that makes sense... `print()` will screw things up because it gets inserted in front of the JSON response |
[10:14:43] | <mstenta[m]> | you could try `drupal_set_message()` instead of `print()` |
[10:14:48] | <mstenta[m]> | although that might not show the output anywhere |
[10:19:25] | <skipper_is[m]> | Can't seem to even get console.log() to print anything out in console... |
[10:19:43] | <mstenta[m]> | did you try `select`? |
[10:21:25] | <skipper_is[m]> | Select shows up, but the ajax doesn't seem to work there either |
[10:22:26] | <mstenta[m]> | hmm ok - revert back to `checkbox` |
[10:22:36] | <skipper_is[m]> | `Notice: Undefined index: values in farm_quick_machinery_form()` |
[10:22:41] | <mstenta[m]> | and try commenting out the `#states` stuff in `$form['quick_machinery']['fault']['faultform']` |
[10:22:41] | <skipper_is[m]> | Huh.... |
[10:22:45] | <skipper_is[m]> | `$form_state['values']['faultcheck']` |
[10:22:53] | <skipper_is[m]> | Is the line it is refering to.. |
[10:23:05] | <mstenta[m]> | oh hm |
[10:23:26] | <mstenta[m]> | oh i know why |
[10:23:37] | <mstenta[m]> | on the initial form load, there are no values |
[10:23:47] | <mstenta[m]> | check out how they do it here: https://drupal.stackexchange.com/questions/169491/how-to-call-ajax-on-ch... |
[10:24:00] | <mstenta[m]> | `$checkbox = !empty($form_state['values']['checkbox']) ? $form_state['values']['checkbox'] : 0;` |
[10:24:01] | <skipper_is[m]> | Ah yea |
[10:24:05] | <skipper_is[m]> | just came to the same conclusion |
[10:24:40] | <mstenta[m]> | this would be my next guess: |
[10:24:40] | <mstenta[m]> | > and try commenting out the `#states` stuff in `$form['quick_machinery']['fault']['faultform']` |
[10:25:10] | <mstenta[m]> | maybe the ajax is working, but that isn't |
[10:25:28] | <skipper_is[m]> | Ah indeed, that was a previous attempt :) |
[10:29:19] | <skipper_is[m]> | Still no joy... |
[10:30:41] | <skipper_is[m]> | When ajax callback is called, what is it executing from the main form creation code? |
[10:30:45] | <skipper_is[m]> | all of it? |
[10:31:32] | <skipper_is[m]> | Like for example is it going to re-call the drupal_set_message again? |
[10:31:50] | <skipper_is[m]> | Or only if it is in the ajax function? |
[10:32:07] | <mstenta[m]> | yes it runs the entire form build function again |
[10:32:23] | <mstenta[m]> | with the addition of `$form_state['values']` |
[10:32:41] | <mstenta[m]> | and then the ajax callback functions just returns PART of the rebuilt form (the part that will replace what's in the wrapper) |
[10:33:09] | <skipper_is[m]> | So it will assign the form_State value to $checkbox |
[10:33:13] | <skipper_is[m]> | and then test if it's 1/0 |
[10:33:27] | <mstenta[m]> | yep |
[10:34:10] | <skipper_is[m]> | so if I do drupal_set_message somewhere in the main form, with it printing out the checkbox value, it should change? |
[10:34:46] | <mstenta[m]> | well... |
[10:34:50] | <mstenta[m]> | should what change? |
[10:34:58] | <skipper_is[m]> | $checkbox = !empty($form_state['values']['faultcheck']) ? $form_state['values']['faultcheck'] : 0; |
[10:35:00] | <skipper_is[m]> | I've got that |
[10:35:11] | <skipper_is[m]> | then I've got drupal_set_message($checkbox) |
[10:35:16] | <mstenta[m]> | ok |
[10:35:18] | <skipper_is[m]> | which by default is 0 when there is no form_State |
[10:35:35] | <mstenta[m]> | so the problem is... `drupal_set_message()` messages don't always get shown inside the ajax wrapper |
[10:35:41] | <skipper_is[m]> | ah nuts |
[10:35:47] | <mstenta[m]> | i forget... you might need to do something special for it to show up |
[10:35:48] | <mstenta[m]> | but... better idea... |
[10:35:57] | <mstenta[m]> | `watchdog('test', $checkbox);` |
[10:36:02] | <skipper_is[m]> | hmm ok |
[10:36:06] | <mstenta[m]> | then look at Recent Log Messages |
[10:36:27] | <mstenta[m]> | this is where xdebug would make this a breeze ;-) |
[10:36:58] | <skipper_is[m]> | ACTION uploaded an image: (4KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/ZGVCqBEwdVE... > |
[10:37:03] | <skipper_is[m]> | So that's working... |
[10:37:13] | <mstenta[m]> | ok! |
[10:37:52] | <mstenta[m]> | ok here's an idea... it probably won't make any difference but... i notice you're mixing dashes and underscores in your wrapper div ID |
[10:37:59] | <mstenta[m]> | try just using dashes |
[10:38:16] | <skipper_is[m]> | Ok, I wasn't sure with the IDs whether they had to matchish the form structure |
[10:38:38] | <mstenta[m]> | the ID can be whatever you want... but i'm wondering if the underscore is throwing things off somehow |
[10:38:51] | <skipper_is[m]> | ah ok |
[10:38:59] | <skipper_is[m]> | ...solved it... |
[10:39:03] | <skipper_is[m]> | Wasn't that |
[10:39:06] | <skipper_is[m]> | wapper... not wrapper... |
[10:39:13] | <mstenta[m]> | AHHHH! lol |
[10:39:21] | <skipper_is[m]> | Oh... hasn't sovled it |
[10:39:24] | <skipper_is[m]> | *solved |
[10:39:24] | <mstenta[m]> | 🎉 |
[10:39:55] | <skipper_is[m]> | Indeed... |
[10:39:58] | <mstenta[m]> | this is a roller coaster of emotions |
[10:40:26] | <skipper_is[m]> | Oh I know right! |
[10:40:38] | <skipper_is[m]> | So, switching it from no to yes works |
[10:40:42] | <skipper_is[m]> | but switching it back... not so much |
[10:40:54] | <skipper_is[m]> | ACTION uploaded an image: (14KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/mtjGFVcABXj... > |
[10:41:01] | <mstenta[m]> | ah interesting |
[10:41:07] | <skipper_is[m]> | Does it need an else? |
[10:41:36] | <mstenta[m]> | "Error cannot create references to/from string offsets..." ? |
[10:41:56] | <mstenta[m]> | i might need to see the current code again |
[10:42:17] | <skipper_is[m]> | the full error report clears it up completely.... Just says the same thing... |
[10:43:43] | <skipper_is[m]> | https://pastebin.com/jzuTfGii |
[10:44:16] | <mstenta[m]> | ah... |
[10:44:26] | <skipper_is[m]> | oh....? |
[10:46:15] | <mstenta[m]> | hmm.. |
[10:46:28] | <mstenta[m]> | what if you change `if ($checkbox == 1){` to `if (!empty($checkbox)){` |
[10:47:08] | <skipper_is[m]> | Same |
[10:47:55] | <skipper_is[m]> | Reports has logged two errors for it: `Warning: Illegal string offset 'value' in drupal_array_set_nested_value() (line 6855 of /var/www/html/farmOS/includes/common.inc).` |
[10:48:04] | <skipper_is[m]> | and `Error: Cannot create references to/from string offsets in drupal_array_set_nested_value() (line 6855 of /var/www/html/farmOS/includes/common.inc).` |
[10:50:16] | <mstenta[m]> | hmm |
[10:51:44] | <mstenta[m]> | i have to hop on a call in a bit... |
[10:51:52] | <skipper_is[m]> | No worries |
[10:52:01] | <mstenta[m]> | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_... |
[10:52:21] | <mstenta[m]> | something's going wrong with the variables passed to that function - but i have no idea what |
[10:52:37] | <mstenta[m]> | if you had xdebug you could put a breakpoint in there to backtrace it :-) |
[10:52:53] | <mstenta[m]> | nothing jumps out as wrong in your code right now... |
[10:53:08] | <mstenta[m]> | (assuming the pastebin is up to date) |
[10:53:31] | <skipper_is[m]> | It has changed now as I put a watchdog in there to see whether the checkbox was changing back |
[10:53:34] | <skipper_is[m]> | but apart from that |
[10:53:40] | <mstenta[m]> | can you comment out everything in `if ($checkbox == 1){` and replace it with just a simple markup element? |
[10:54:01] | <mstenta[m]> | `$form['quick_machinery']['fault']['#markup'] = 'test';` |
[10:54:11] | <mstenta[m]> | oops... |
[10:54:20] | <mstenta[m]> | `$form['quick_machinery']['fault']['test']['#markup'] = 'test';` |
[10:54:44] | <skipper_is[m]> | $form['quick_machinery']['fault']['test'] = array( |
[10:54:45] | <skipper_is[m]> | '#markup'=>'test' |
[10:54:45] | <skipper_is[m]> | ); |
[10:54:47] | <mstenta[m]> | (i'm just trying to isolate things down to the bare bones ajax) |
[10:55:20] | <skipper_is[m]> | That seems to work |
[10:55:23] | <mstenta[m]> | gotta go... good luck! let me know if you figure it out or find other clues! |
[10:55:28] | <mstenta[m]> | oh?? |
[10:55:37] | <skipper_is[m]> | I'll rebuilt the form from scratch and see if there is something weird with it |
[10:59:52] | <skipper_is[m]> | `$form['quick_machinery']['fault']['faultform']['description']` vs `$form['quick_machinery']['description']` potentially.... |
[11:00:07] | <skipper_is[m]> | rebuilt with different field names, and it seems to work |
[11:09:30] | <paul121[m]> | *paul121 promotes skipper_is to AJAX wizard 🪄 |
[11:10:08] | <paul121[m]> | A significant achievement! |
[11:28:26] | <skipper_is[m]> | Apprentice maybe... :) |
[12:43:03] | <paul121[m]> | ohhhh! would the [composer merge plugin](https://github.com/wikimedia/composer-merge-plugin) help us with some of our composer/js related issues?? |
[12:43:26] | <paul121[m]> | just read this documentation from the webform module: https://www.drupal.org/node/3003140 |
[12:43:33] | <paul121[m]> | they depend on a lot of JS libraries |
[12:44:38] | <paul121[m]> | If I understand correctly, we could define a `composer.libraries.json` in `farmOS/farmOS` which could hold things like the `farmOS-map` repository/dependency info |
[12:45:08] | <paul121[m]> | as we expand to include things like charts, we might introduce some other JS dependencies too... |
[12:45:24] | <mstenta[m]> | oh interesting! |
[12:46:09] | <paul121[m]> | this might be a reason to not use asset packagist even |
[12:47:09] | <symbioquine[m]> | Hmmm, I'm not sure managing JS dependencies (except for the very top level ones) with Composer is a good plan. |
[12:47:17] | <paul121[m]> | the webform [composer.libraries.json](https://git.drupalcode.org/project/webform/-/blob/6.x/composer.libraries...) for example |
[12:47:30] | * irissc[m] has joined #farmos |
[12:49:19] | <paul121[m]> | I think the main motivation is that for someone setting up their own composer project this could make things easier. IIRC right now they would need to bump the farmOS-map version themselves ? |
[12:49:43] | <paul121[m]> | * I think the main motivation is that for someone setting up their own composer project this could make things easier. <del>IIRC right now they would need to bump the farmOS-map version themselves ?</del> |
[12:50:24] | <symbioquine[m]> | I might not be following the use-case you're describing... |
[12:51:12] | <paul121[m]> | nah, they just need to define `installer-paths: web/libraries/farmOS-map: 'npm-asset/farmos.org--farmos-map'` themselves, and the `farmOS/farmOS` composer.json defines the required version |
[12:51:53] | <paul121[m]> | if/when farmOS core depends on more JS libraries, these similar `installer-paths` would have to be added to the composer project, which farmOS doesn't control |
[12:52:33] | <paul121[m]> | but this is also tricky, because someone doesn't need the map or charts, then they shouldn't have to include all of those JS libraries |
[12:52:39] | <paul121[m]> | * but this is also tricky, because if someone doesn't need the map or charts, then they shouldn't have to include all of those JS libraries |
[12:53:02] | <symbioquine[m]> | Ahhh, actually I think I was running into something similar... |
[12:54:00] | <symbioquine[m]> | I don't think there's a way for a contrib module to control where it or it's dependencies end up getting installed to. |
[12:54:19] | <paul121[m]> | right |
[12:55:10] | <paul121[m]> | and with the case of the webform module, they have so many library dependencies that I assume are pretty critical, so this method makes it much easier for the admin to manage |
[12:56:12] | <paul121[m]> | if we provided a `composer.libraries.json` it would still be an optional thing... so the composer project admin could define & update the libraries overtime if they wanted |
[12:56:43] | <mstenta[m]> | Hmm... so would there be a project-level `composer.libraries.json` AND a farmOS-level `composer.libraries.json`? |
[12:56:44] | <paul121[m]> | * if we provided a `composer.libraries.json` it would still be an optional thing... so the composer project admin could define & update the libraries overtime if they wanted (on their own) |
[12:57:17] | <paul121[m]> | no, I think just a farmOS-level one |
[12:57:36] | <paul121[m]> | ACTION < https://libera.ems.host/_matrix/media/r0/download/libera.chat/437a27d8fa... > |
[12:57:49] | <paul121[m]> | ACTION < https://libera.ems.host/_matrix/media/r0/download/libera.chat/3a5ab0d6cc... > |
[12:57:49] | <mstenta[m]> | oh interesting |
[12:58:15] | <mstenta[m]> | so... does `web/profiles/farm/composer.libraries.json` define the install path? |
[12:59:33] | <mstenta[m]> | oh hmm... wasn't one of the limitations that we can't put `repositories` in the farmOS `composer.json`? it needs to be in the top level... that's why we couldn't just pull a tarball directly without hardcoding the version in the top level `composer.json` |
[12:59:40] | <mstenta[m]> | unless this "merges" that repository information up to the top level? |
[12:59:58] | <paul121[m]> | <paul121[m] "the webform [composer.libraries."> exactly! check this example |
[13:00:13] | <mstenta[m]> | cool! yea grokking that now... |
[13:00:47] | <mstenta[m]> | if this is as good as it sounds, it would certainly simplify some things! |
[13:01:04] | <mstenta[m]> | and the fact that wikimedia and webform both use it is very encouraging |
[13:01:15] | <paul121[m]> | I think the composer project admin would be responsible for defining the path the the farmOS `composer.libraries.json` to match where they installed it. that is a little unclear to me too |
[13:01:36] | <paul121[m]> | * I think the composer project admin would be responsible for defining the path the the farmOS `composer.libraries.json` to match where they installed *the farm profile. that is a little unclear to me too |
[13:02:49] | <paul121[m]> | so symbioquine your contrib module could provide a `composer.libraries.json` file too, but it would be the same "opt-in" approach |
[13:03:18] | <paul121[m]> | not sure if there is a way around that.. |
[13:09:38] | <mstenta[m]> | what do you mean by "opt-in" approach? |
[13:11:37] | <paul121[m]> | needing to manually add to the `merge-plugin/include` array in the composer project |
[13:14:48] | <mstenta[m]> | ah ok |
[13:15:50] | <mstenta[m]> | so for contrib modules that need to add libraries, they'll need to provide their own `composer.libraries.json`, and when someone wants to use it they'll need to BOTH `composer require [contrib-project]` AND edit their `composer.json` file to reference the contrib module's `composer.libraries.yml`'? |
[13:22:41] | <paul121[m]> | yep |
[13:24:23] | <paul121[m]> | the `composer.json` would need to be updated to include the libraries regardless, so `composer-merge-plugin` helps automate that a bit. and importantly, lets the dependency manage the repositories going forward |
[13:25:22] | <paul121[m]> | an alternative is a README.txt with instructions on how to do it manually.... like the `charts` module does :-P https://git.drupalcode.org/project/charts/-/blob/5.0.x/modules/charts_ch... |
[13:25:58] | <mstenta[m]> | Hey all - unrelated but AgStack (Linux Foundation project) just set up a Slack: slack.agstack.org - I started a channel to explore using the farmOS data model for the AgStack "events" concept... |
[13:26:08] | <mstenta[m]> | https://agstackfoundation.slack.com/archives/C025EAMK9GT |
[13:26:49] | <mstenta[m]> | Would love to have some more folks from the farmOS community join! |
[13:31:45] | <skipper_is[m]> | Joined |
[14:59:38] | <skipper_is[m]> | Very odd.... I uninstalled my custom module, and it uninstalled a core farmOS module - Equipment..... |
[14:59:51] | <skipper_is[m]> | (As well as my module) |
[15:08:18] | <mstenta[m]> | Hmm |
[15:08:26] | <mstenta[m]> | this is in 1.x? or 2.x? |
[15:10:07] | <skipper_is[m]> | 1.x |
[15:10:43] | <mstenta[m]> | Did your module depend on `farm_equipment`? (That shouldn't cause this, but curious) |
[15:11:02] | <skipper_is[m]> | It doe |
[15:11:03] | <skipper_is[m]> | does |
[15:11:07] | <skipper_is[m]> | But wy should it uninstall it? |
[15:11:17] | <mstenta[m]> | It shouldn't |
[15:11:24] | <mstenta[m]> | Does your module provide any log types? |
[15:11:40] | <skipper_is[m]> | Nope, category type, but not log |
[15:11:45] | <shane_aldrich[m]> | ACTION uploaded an image: (50KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/FpgWssufiWl... > |
[15:11:49] | <shane_aldrich[m]> | Has something changed in Alpha2 regarding installing modules? I'm trying to install the Devel module from a downloaded `tar.gz` right now and I'm getting the following message when I click `Install`: |
[15:12:01] | <shane_aldrich[m]> | This didn't happen with Alpha 1 |
[15:12:31] | <mstenta[m]> | shane_aldrich: I don't think anything changed - but I would not recommend using that UI for installing modules |
[15:12:48] | <mstenta[m]> | You can just download the tarbal file itself and extract it in `sites/all/modules` |
[15:33:36] | <shane_aldrich[m]> | <mstenta[m] "You can just download the tarbal"> Worked like a charm! Thanks! |
[17:01:05] | <mstenta[m]> | Hey would anyone be interested in representing farmOS at this? https://farmos.discourse.group/t/invitation-to-speak-at-environmentally-... |
[17:07:32] | <mstenta[m]> | oh crap it's tomorrow lol |
[17:07:37] | <mstenta[m]> | oops :-) |
[17:09:36] | <paul121[m]> | yea.. it was too last minute & high profile for me to mentally prepare for |
[17:09:47] | <paul121[m]> | streaming everywhere haha |