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

Select Field integer default value -> value displayed instead of text #1816

Closed
krausste opened this Issue Mar 1, 2018 · 12 comments

Comments

Projects
None yet
3 participants
@krausste

krausste commented Mar 1, 2018

Expected behaviour

The text of the default option is shown instead of the value.
And the value is saved without enclosing quotes (which might be the cause of the issue somehow - after choosing another option the int value is saved without quotes).

Actual behaviour

The default value is shown instead of the text that belongs to the default's value option.

Steps to reproduce

  1. Add a Select field to any of your fieldsets
  2. Add a default value of type integer to this field
  3. Add an option with this value and add a text to it

Server Details

Statamic Version: 2.8.7

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 4, 2018

This is working as intended now in 2.9.x. Please reopen if you find a condition otherwise!

@jackmcdade jackmcdade closed this Jun 4, 2018

@krausste

This comment has been minimized.

krausste commented Jun 5, 2018

Hi Jack, unfortunately this is still not working for us in 2.9.6.
I will add some screenshots.
Can you please reopen the ticket? Thank you!
select field int default value - fieldset config 1-3
select field int default value - fieldset config 2-3
select field int default value - fieldset config 3-3
select field int default value - contentstore new
select field int default value - contentstore labels

@jackmcdade jackmcdade reopened this Jun 5, 2018

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 5, 2018

Alright, trying again with his exact setup. 🙏

@krausste

This comment has been minimized.

krausste commented Jun 5, 2018

great! thank you :)

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 5, 2018

Confirmed. I must have been testing it wrong. Will get it fixed up for 2.9.7. 👍

@jackmcdade jackmcdade self-assigned this Jun 5, 2018

@jackmcdade jackmcdade added the bug label Jun 5, 2018

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 5, 2018

Found it. The default is probably stored as a string, and therefore not matching the int value in the options object. With a little type coercion, we're back in business.

If you need this fixed immediately, you can pop open the fieldset yaml file directly and remove any string quotes:

options:
  1: First
  2: Second
  3: Third
default: '2' # change to 2
@krausste

This comment has been minimized.

krausste commented Jun 6, 2018

Alright, thank you!

@jackmcdade jackmcdade closed this Jun 7, 2018

@krausste

This comment has been minimized.

krausste commented Jun 11, 2018

Hi there, this is still not fixed in 2.9.8.
default int values are still stored with quotes inside the yaml config file.

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 11, 2018

Correct, we couldn't change that, but the loading side checks if the string is numeric and type casts it back to an int so the display shows correctly. You said it's not fixed because it's not saved as an int, but does it work as expected?

@krausste

This comment has been minimized.

krausste commented Jun 11, 2018

Nope, also not working as expected.
Only when removing the quotes manually its working.

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Jun 11, 2018

Can you post the fieldset config for the field you're using?

@krausste

This comment has been minimized.

krausste commented Jun 11, 2018

sure. see field_9 and quote set inside the bard field

title: Long Form Post
hide: true
sections:
  main:
    display: Main
    fields:
      title:
        type: text
        display: Title
        localizable: true
      section_1:
        type: section
        display: Section 1
      template:
        type: hidden
        default: blog/long_form
      long_form:
        type: bard
        display: Long Form Content
        sets:
          image:
            display: Image
            fields:
              photo:
                display: Photo
                type: assets
                container: main
                folder: img
                max_files: 1
              caption:
                type: text
              size:
                type: radio
                default: Normal
                options:
                  Normal: Normal
                  Oversized: Oversized
          quote:
            display: Pull Quote
            fields:
              quote:
                display: The Quote
                type: markdown
              cite:
                type: text
                display: Cite
              select:
                type: select
                display: Select
                options:
                  10: Label 1
                  20: Label 2
                  30: Label 3
                default: "10"
          grid:
            display: Grid
            fields:
              grid:
                type: grid
                display: Grid
                fields:
                  text:
                    type: text
                    display: Text
                  text_2:
                    type: text
                    display: Text 2
                  togggle:
                    type: toggle
                    display: Togggle
                mode: table
        spellcheck: true
        allow_source: true
      section_2:
        type: section
        display: Section 2
      text:
        type: text
        display: Text
      tags:
        type: taxonomy
        taxonomy: tags
      field_9:
        options:
          1: label 1
          2: label 2
        type: select
        display: Field 9
        default: "1"
taxonomies: true

@jasonvarga jasonvarga reopened this Jun 11, 2018

@jackmcdade jackmcdade closed this Jul 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment