thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Documentation for Dropdown #2158

Closed lloy0076 closed 3 years ago

lloy0076 commented 6 years ago

Description:

Broken Version

Docs claim that dropdowns are setup like:

{
    "default": "",
    "options": {
        "m": "Male",
        "f": "Female"
    }
}

Notice the word options [sic].

Fixed Version

It should be option - notice the missing letter s:

{
    "default": "",
    "option": {
        "m": "Male",
        "f": "Female"
    }
}

Steps To Reproduce:

  1. Make a dropdown field called "gender" or whatever;
  2. Insert the first one or even just copy/paste from the docs;
  3. Watch the horrid exception;
  4. Remove the 's';
  5. Watch everything work.
fletch3555 commented 6 years ago

Why should it be option? Looking at the code (both the tagged v0.11.14 and master branch.. see links below), it's looking for options with the 's'.

v0.11.14: https://github.com/the-control-group/voyager/blob/v0.11.14/resources/views/formfields/select_dropdown.blade.php#L18 master: https://github.com/the-control-group/voyager/blob/master/resources/views/formfields/select_dropdown.blade.php#L18

lloy0076 commented 6 years ago
(2/2) ErrorException

Undefined property: stdClass::$ (View: C:\laragon\webroots\playhq\attendence-laravel\vendor\tcg\voyager\resources\views\bread\browse.blade.php)

image

I agree - options should work but it's not (at least for me).

lloy0076 commented 6 years ago

@fletch3555 - all I know is that changing it from options to just option fixes it all.

lloy0076 commented 6 years ago

This might be an issue but I don't see how this would affect it.

BreadRelationshipParser.zip

lloy0076 commented 6 years ago

More information - on the edit view, no dropdown is created when the word option (no s) is used, so @fletch3555:

  1. The column/list view (the thing that just a plain slug goes to) has the issue;
  2. The code "ignores" a JSON option option in the edit view and renders it as an empty relation
fletch3555 commented 6 years ago

Yeah, seems options is perfectly correct, but is manifesting as the problem, hiding the real problem. This is going to take a bit more digging to figure out. I haven't had much time lately, and haven't been able to reproduce it locally, so if someone else can, please feel free to take lead on troubleshooting

prezmix commented 6 years ago

Just wanted to comment that I have the same issue. Using options:

Undefined property: stdClass::$Lobby (View: /var/www/zoomrec/vendor/tcg/voyager/resources/views/bread/browse.blade.php)

Changing to option results in the same bug as described by @lloy0076 above with no dropdown generated when editing.

emptynick commented 5 years ago

Is this still a problem? Looking at the code options is the correct key.

kvlknctk commented 5 years ago

Why should it be option? Looking at the code (both the tagged v0.11.14 and master branch.. see links below), it's looking for options with the 's'.

v0.11.14: https://github.com/the-control-group/voyager/blob/v0.11.14/resources/views/formfields/select_dropdown.blade.php#L18 master: https://github.com/the-control-group/voyager/blob/master/resources/views/formfields/select_dropdown.blade.php#L18

link broken

fletch3555 commented 5 years ago

Likely because 0.11.14 was released like 2+ years ago and we pruned away most of the pre-1.0 tags. You're quoting a comment from 2.5+ years ago, and related to a MUCH older version, so it's not likely to be relevant anyway

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.