adminarchitect / core

AdminArchitect - Active Admin for Laravel
http://adminarchitect.com
MIT License
211 stars 66 forks source link

Problem doing article example #44

Closed andersonpem closed 5 years ago

andersonpem commented 5 years ago

Hello. I'm using this video as reference to learn AdminArchitect:

https://www.youtube.com/watch?v=sLqjm90RZxI

The model and migration were created correctly. But I can't get the status field to work correctly. It shows as a text box.

The article module has the code overriding the form function:

    public function form(){
            return array_merge(
                $this->scaffoldForm(), ['status' => \admin\form\select('Status',['draft'=>'Draft', 'published'=>'Published'])]
            );
    }

Laravel returns me this error:

array_merge(): Argument #1 is not an array (View: /var/www/resources/views/vendor/administrator/edit/index.blade.php)

the scaffoldForm() method returns me a mutable class, not an array. Could that be the cause?

A dd from the scaffoldform():

Mutable {#1128 ▼
  #items: array:3 [▼
    0 => FormElement {#1109 ▼
      #input: Text {#1098 ▶}
      #description: null
      #template: null
      #relations: null
      #standalone: false
      #keepOriginalID: false
      #id: "title"
      #title: "Title"
      #module: null
      #translator: null
    }
    1 => FormElement {#1116 ▼
      #input: Textarea {#1114 ▶}
      #description: null
      #template: null
      #relations: null
      #standalone: false
      #keepOriginalID: false
      #id: "body"
      #title: "Body"
      #module: null
      #translator: null
    }
    2 => FormElement {#1123 ▼
      #input: Text {#1121 ▶}
      #description: null
      #template: null
      #relations: null
      #standalone: false
      #keepOriginalID: false
      #id: "status"
      #title: "Status"
      #module: null
      #translator: null
    }
  ]
}

a dd from the custom field array:

array:1 [▼
  "status" => array:3 [▼
    "type" => "select"
    "label" => "Status"
    "options" => array:2 [▼
      "draft" => "Draft"
      "published" => "Published"
    ]
  ]
]

Environment

Could you help me with that? Thanks in advance :)

endihunter commented 5 years ago

@andersonpem videos on youtube are outdated, they are for very first version. for current version please follow the documentation http://docs.adminarchitect.com/#/Forms/forms

andersonpem commented 5 years ago

Oh. I see. I'l check it out. Thanks Endi! :)