Twig - how use dropDownList


(Luk Azn) #1

I have static method inside model


    public static function getPostType(){

        return [

            1 => 'Post 1',

			2 => 'Post abc',

			3 => 'Post xyz',

        ];

    }

Inside view.twig




{{ use('app/models/Post') }}

{{ form.field(model, 'type').dropDownList(Post.getPostType | raw }}

and error

What is incorrect?


(Jennifergeorge) #2

Hi,

I think you can omit get , simply use postType.

$form->field($model, ‘title’)->dropDownList( $post->postType );

:)


(Luk Azn) #3

I use Twig template.


(Luk Azn) #4

bump :)


(willkayz) #5

Hello any luck on solving this error…?