Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By darrenlambert on
Hi Everyone
I have just written my first module, which went really well.
How do I set the default value for a property of a new node?
I have a 'visible' property, which has a checkbox to allow selection of the value, on the edit form.
When the [module]_form hook gets called I pass the node->visible property as the initial value, to ensure the user can edit the current value.
However, I want the 'visible' property to default to 1 when the new node is created, i.e. before the edit form appears. Or does the node get created after the edit form is submitted?
Thanks
Darren