There are certain modules that only need and want to work with newly saved content (system objects) after a UI-based submission - disregarding programmatic insertions.

I always wondered why we cannot simply make this information available to form submit handlers that run after the primary submit handler.

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

dries’s picture

Not sure we need to save both the object and the object ID. Either way, I agree that this is the right thing to do.

IMO, it should be a best practice because it avoids a lot of ugly code in contributed modules. If we think it is a good best practice, it might be good to document this in form.api.php.

Update: oops, there is no form.api.php yet, it seems. Can't have everything in one release, I guess. ;-)

Status: Needs work » Needs review

chx requested that failed test be re-tested.

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new3.44 KB

I realized that we need to revamp the entity handling in $form_state in #367006: [meta] Field attach API integration for entity forms is ungrokable anyway, so populating $form_state[$entity] here makes no sense.

So this one just populates the entity id in the values after saving.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

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

sun’s picture

Title: Make saved objects available to form submit handlers » Make entity ids available to form submit handlers
Status: Closed (fixed) » Needs review
StatusFileSize
new5.43 KB

I need the same to happen for entity delete confirmation forms. That's partially in place already, but not consistently for all forms.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

looks reasonable to me.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD, thanks.

I suppose there's no way to programmatically derive the key field (for example, via schema API)? This is something that 99.9% of module developers are going to forget to do. :\

Status: Fixed » Closed (fixed)

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