When creating a new block the saved bean object is not assigned to the $form_state. So when trying to use the new
auto created object data(ex. delta or bid) in a form submission handler and assign it to other modules we get NULL values.
Simply adding $form_state['values']['bean'] = $bean; after the $bean->save() method is called in bean_form_submit function
is solving the problem.

Comments

k.minkov’s picture

StatusFileSize
new548 bytes
k.minkov’s picture

Status: Active » Patch (to be ported)
k.minkov’s picture

Priority: Minor » Normal
Status: Patch (to be ported) » Active
k.minkov’s picture

Status: Active » Needs review
saltednut’s picture

Status: Needs review » Needs work
+++ b/includes/bean.pages.incundefined
@@ -382,6 +382,7 @@ function bean_form_submit($form, &$form_state) {
   $insert = $bean->internalIdentifier();
   field_attach_submit('bean', $bean, $form, $form_state);
   $bean->save();

Shouldn't we only do the array assignment inside if ($bean->save()) {} to make sure this is complete?

k.minkov’s picture

This will not change anything actually, because in bean_form_validate there is an assignment already:

$form_state['values']['bean'] = $bean;

which assigns NULL when adding bean and the bean object itself on edit.
So the 'bean' element of $form_state['values'] is already set at this point.

saltednut’s picture

Status: Needs work » Reviewed & tested by the community

...we get NULL values.

Ah duh - okay, this looks good to me.

saltednut’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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