From e9980ff9fd82ed4c7f7629089ec4ad789bda3d3c Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 6 Sep 2022 20:08:04 +1000 Subject: [PATCH] Get value() by block_id when it isnt a form submission --- src/Interactive/ViewSubmission.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Interactive/ViewSubmission.php b/src/Interactive/ViewSubmission.php index 1702632..3a275ad 100644 --- a/src/Interactive/ViewSubmission.php +++ b/src/Interactive/ViewSubmission.php @@ -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 { - return object_get($this->state->get($block_id),$action_id.'.value'); + // 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'); + } } } \ No newline at end of file