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