Get value() by block_id when it isnt a form submission

This commit is contained in:
Deon George 2022-09-06 20:08:04 +10:00
parent 145e322317
commit e9980ff9fd

View File

@ -61,8 +61,15 @@ class ViewSubmission extends Base
return new Modal;
}
public function value(string $block_id,string $action_id): ?string
public function value(string $block_id,string $action_id=NULL): ?string
{
// If there is no state we need to search out blocks for the block_id
if (! $this->state->count()) {
$block = $this->blocks->search(function($item) use ($block_id) { return $item->block_id == $block_id; });
return $block !== FALSE ? object_get($this->blocks->get($block),$action_id) : NULL;
} else {
return object_get($this->state->get($block_id),$action_id.'.value');
}
}
}