I am trying to port over a D7 module and am stuck on how to do this step. How can I enter values into a node add form (that the user can override if desired)?
The code sets the [#default_value]
for the form field, i.e.
foreach ($isbn2book_data as $field => $default_value) { switch ($field) { case 'title': $form[$field]['#default_value'] = $default_value; break; default: $form[$field]['und']['0']['value']['#default_value'] = $default_value; break; } }
It works in D7. The form object appears to have the same structure in Backdrop, but the (converted) code doesn't work on it. If I print a debug message with the value of the $form
object, I can see that the default values are set correctly, but they don't show up on the form display.
Any help appreciated!
(Following up on the book data module topic here: https://forum.backdropcms.org/forum/book-data-module)
Hi @leeksoup.
Compare the top of the function call. If you used Coder Upgrade on PHP 8+ then it often strips out the & from parameters, so
&$form_state
becomes$form_state
Sounds like this might be the case here