Bring area name in log activity

Activity 03/14/2021 - 17:49 796
After registering the log, the selected field name appears in the name section. (796). Can I bring the area name in the first login section without registering the log?

I want to bring the area name to the place where it says log activity in the picture.

1 Like

This behavior is actually handled by the Drupal Log module (one of farmOS’s dependencies, but not specifically farmOS):

This is handled in hook_log_insert() (which runs when a new Log entity is inserted in the database) and hook_log_update() (when an existing Log is updated):

Both of these hooks delegate to the log_name_generate() function: log.module · 04117ccd01316c78ac68efbb5d1e25c0a3a041f7 · project / log · GitLab

So these only fire AFTER the form is submitted, but it sounds like you want to pre-fill the form with the same value. You may be able to do this with a custom implementation of hook_form_alter() - this will fire whenever a form is built in the system. So you would want to limit it to only fire when the Log edit form is built AND you would want to make sure it only runs if the field is empty, otherwise it could overwrite previously saved values.

Here’s the Drupal doc page for hook_form_alter():!system!system.api.php/function/hook_form_alter/7.x

Hope that helps!