getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

Default values of some field types are not displayed correctly in the Panel #2460

Closed SkidX closed 1 year ago

SkidX commented 4 years ago

Describe the bug
The default value of some field types is not showed correctly in the Panel when the field is added to an existing page.

Affected field types I discovered so far: text, textarea, checkboxes, radio, multiselect

Field types not affected: toggle

To Reproduce

  1. Add a checkboxes field on a blueprint, with a default value
    fields:  
    categories:  
    label: Categories
    type: checkboxes
    default: architecture
    options:
      design: Design
      architecture: Architecture
      photography: Photography
      3d: 3D
      web: Web
  2. Open a page using that blueprint in the Panel

Expected behavior
The Architecture checkbox should appear checked, it is not.

Kirby Version
3.3.3

Desktop

Additional context
Inside Builder blocks, the default value of text, textarea and select fields is enforced correctly, while checkboxes, radio and multiselect fail as well.

afbora commented 4 years ago

@SkidX Thanks for detailed reporting but this is not issue. As it is written in the documents:

Default value for the field, which will be used when a page/file/user is created

SkidX commented 4 years ago

Hi Ahmet, thanks for the quick reply! Well, if that is the expected behavior, I would say it is still buggy, since the default value is enforced for toggle fields without the need to create a new page, so it is somehow not reliable accross all the field types.

I would also add that it was working as I would expect back in Kirby 2. Clearly the decision is up to you, but I would suggest to consider it as a regression, since it's kind of worse to not have this possibility anymore.

afbora commented 4 years ago

You right! When I examine the toggle field, a definition is made for the default as your said: https://github.com/getkirby/kirby/blob/3.3.3/config/fields/toggle.php#L42-L48

It obviously works similarly when I apply it to the text field, but I have no idea why it is not applied to others except the toggle field. Team members will give us an idea on this issue.

lukasbestle commented 4 years ago

I agree that all fields should use the default value if the field value is empty. I'm not sure why we have this inconsistency right now, maybe @distantnative or @bastianallgeier can tell us more. I assume it was just an oversight.

ralfgoeke commented 3 years ago

I just stumbled over this issue, while refactoring some old blueprints. So I do have a lot of files and pages now, which won't reflect default values properly after I changes the templates. I'd appreciate if you guys could have another look on it. :-*

distantnative commented 3 years ago

@bastianallgeier There are two options:

  1. Fix toggle field to also only apply its default value at model creation
  2. Reconsider why in v3 the default value is only applied at model creation but not at any time a field does not exist in the content file
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.