πŸ‡ΊπŸ‡ΈUnited States @gpotter

Account created on 15 August 2017, over 7 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States gpotter

On the commit from #8, I got it working by changing:

```
return $element['#default_value'] ? (string) $element['#default_value'] : NULL;
```

To

```
return isset($element['#default_value']) && is_scalar($element['#default_value']) ? (string) $element['#default_value'] : NULL;
```

Its an odd situation, the main issue comes from the core\lib\Drupal\Core\Form\FormBuilder

```
// Final catch. If we haven't set a value yet, use the explicit default
// value. Avoid image buttons (which come with garbage value), so we
// only get value for the button actually clicked.
if (!isset($element['#value']) && empty($element['#has_garbage_value'])) {
$element['#value'] = $element['#default_value'] ?? '';
}
```

Where default_value is interpreted as a integer. Probably a better solution somewhere else to make sure default_value is cast as a string? Didnt have more time to look into this.

πŸ‡ΊπŸ‡ΈUnited States gpotter

Sorry Abramm you are correct, just really running into these issues now at Drupal 9.5 after never having issues for years. I think many older tutorials make it vague and like its an either/or type of situation where attaching context to listeners is a magic bullet that is really not the case anymore (EX: https://www.lullabot.com/articles/understanding-javascript-behaviors-in-...)

πŸ‡ΊπŸ‡ΈUnited States gpotter

I agree with #7, we have to make a conversion to make this work as well. It was a very easy to understand the concept before of attaching listeners to the context parameter (new html will flow through context once), but now being require to use once() adds additional complexity and boilerplate code.

Production build 0.71.5 2024