Create panel fields from array

Hi is it possible to create fields in the panel from an array ?
I am creating a custom field.

    [0] => Array
            [label] => Text
            [type] => textarea
            [buttons] => Array
                    [0] => link
                    [1] => email

            [name] => text
            [value] => {{text}}

    [1] => Array
            [label] => Image
            [type] => image
            [name] => imager
            [value] => {{imager}}


Where do you generate that array?

Inside a custom panel field. I have looked at the structure field, but feel like its overkill for my field, basically i am doing a repeater field that is javascript based. The user defines the fields in the blueprint, the array is from the blueprint. No modals… Just curious how to do it…

Have you seen the builder field? Maybe you can use that or at least use it as inspiration.

Yes I have. The only function i am after is to be able to echo the default fields from the panel whith the array, have looked everywhere… It might be something like:
New field or New Form?! (Php newbie:)

My plan is then to save it to a hidden field through js…

Well it was not hard to do after all:

public function former() {
      $form = new Kirby\Panel\Form($this->modulars());
      return $form;

But the problem I am facing now is that I cant use “link”, “mail” buttons in the textarea field, and the Image field are not working as well and I can´t use options “images” in select field…
Any help highly appreciated !!

Error :

Fatal error:  Method ImageField::__toString() must not throw an exception in /Users/Fredrik/Sites/kirby/kirby/toolkit/lib/brick.php on line 0