At the moment after a new domain is created the domain_id is stored in $domain. It would be helpful to update the domain_id in $form_state after domain_save is called in domain_form_submit. This would allow other modules also involved in the form submit to have access to the domain_id for their processing. At the moment I think this only applies to domain directory (in development), but could apply to other modules in the future. I've attached a patch that addresses this issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1188682-domain-id-on-save.patch | 660 bytes | agentrickard |
| domain_id_update.patch | 609 bytes | ejustice |
Comments
Comment #1
agentrickardNormally, you should use hook_domain_insert() instead, but I see the point here.
You're testing domain_dir 7.x-1.x, right?
Comment #2
ejustice commentedYes I'm working off domain_dir 7.x-1.x.
The issue at the moment is the way you started domain_dir has it calling domain_dir_form_domain_form_alter(). So the dir creation is being processed as part of the domain form submission and therefore domain_dir isn't the one creating a new domain. Unless I'm misunderstanding the purpose of hook_domain_insert().
Comment #3
agentrickardRight. hook_domain_insert() expects module to act on the $domain after form processing. But here, we need the domain_id because we are adding data to the form.
The "other" way to do this is to run a domain lookup on the subdomain, which should return data (if $reset is TRUE), but this patch is likely better.
Comment #4
agentrickardSince form_set_value() is expressly for validate functions, we can do this a little easier.
Committed to 7.x.3.
Comment #5
agentrickardThis doesn't really apply cleanly to 7.x.2 or 6.x.2 without doing handstands for domain 0, so not committing there.