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.

Comments

agentrickard’s picture

Category: bug » feature

Normally, you should use hook_domain_insert() instead, but I see the point here.

You're testing domain_dir 7.x-1.x, right?

ejustice’s picture

Yes 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().

agentrickard’s picture

Right. 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.

agentrickard’s picture

Status: Needs review » Fixed
StatusFileSize
new660 bytes

Since form_set_value() is expressly for validate functions, we can do this a little easier.

Committed to 7.x.3.

agentrickard’s picture

This doesn't really apply cleanly to 7.x.2 or 6.x.2 without doing handstands for domain 0, so not committing there.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.