Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EDITION] select2 fields doesn't works on edit view #44

Closed
welcoMattic opened this issue Jun 21, 2016 · 1 comment
Closed

[EDITION] select2 fields doesn't works on edit view #44

welcoMattic opened this issue Jun 21, 2016 · 1 comment
Labels
Milestone

Comments

@welcoMattic
Copy link
Contributor

welcoMattic commented Jun 21, 2016

I have an Article model that have an author field (user_id).
In my ArticleCrudController, I add the followed field:

$this->crud->addField([
        'label' => 'Author 
        'type' => 'select2',
        'name' => 'user_id',
        'entity' => 'user',
        'attribute' => 'name',
        'model' => User::class
    ], 'both');

It works fine on create view, but completely not on edit view.
Instead of my select2 field, I see a number field, and it's broken because of this error:

htmlentities() expects parameter 1 to be string, array given. 

Located in number.blade.php.

@tabacitu
Copy link
Member

@welcoMattic , (1) have you found a way around this or is this still a problem?

From what I can see, you're missing a comma there, that might be the issue. Here's how I'd write it:

$this->crud->addField([
        'label' => 'Author' 
        'type' => 'select2',
        'name' => 'user_id',
        'entity' => 'user',
        'attribute' => 'name',
        'model' => 'App\User'
    ], 'both');

(2) Does this work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants