Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DavidStiller's avatar

Pass ActionFields with Array

Hi there, artisans!

Currently i'm working on Dynamic Action Fields. I added a per-row action in my resources index and want to generate a text from gathered related models. Currently i'm struggeling with the problem to return my fields back from Actions' fields() function in the correct format:

public function fields()
    {
        $requirements = $this->model->scrumrequirements()->orderBy('sort')->get();

        if ($requirements->count()) {

            foreach ($requirements as $requirement) {
                $required[] = Text::make("Field" . $requirement->id);
            }

            return $required;

        }

        return [
			Text::make("Field1"),
			Text::make("Field2"),
	    ];
    }

There is a big difference in the resulting response. Back in my Resource the received value from $required is empty and i guess, return as array with using [] to add is the difference. The return below with named is logged as a json key-value pair. So, any hint how i can gather fields in my return?

Thanks Dave

0 likes
1 reply
DavidStiller's avatar
DavidStiller
OP
Best Answer
Level 2

This problem has been solved by passing the model id when the current request method is post.

Please or to participate in this conversation.