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

The default option doesn't work #14

Open
herrajon opened this issue Oct 7, 2020 · 2 comments
Open

The default option doesn't work #14

herrajon opened this issue Oct 7, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@herrajon
Copy link

herrajon commented Oct 7, 2020

Kirby 3.4.3

The plugin seemst to ignore default value which brakes the page with:

Whoops \ Exception \ ErrorException (E_NOTICE)
Undefined index: background

from:

<?php
// Colour Palette
$palette    = $part->palette()->yaml();
 
$background = $palette['background'];
$border = $palette['border'];
$text = $palette['text'];
?>

based on blueprint:

columns:
  colours:
    width: 1/4
    fields:
      palette:
        default: whitex
        label: Litaver
        type: color-palette
        options:
          whitex:
            background: white
            text: black
            border: '#CCCCCC'
          blackx:
            background: black
            text: white
            border: '#CCCCCC'

The user must select colour to not break the page when saved.

This though works with the simple version of the blueprint options but breaks with the more detailed version above:

#simple colors
palette:
  type: color-palette
  default: '#135fdc'
  options:
    - '#135fdc'
    - '#f6917e'

To add it ignores required.

Tried various setups. Without success.

Thx

P.s. Great plugin and thank you

@sylvainjule sylvainjule changed the title Default and Required The default option doesn't work Nov 16, 2020
@sylvainjule sylvainjule self-assigned this Nov 16, 2020
@sylvainjule sylvainjule added the bug Something isn't working label Nov 16, 2020
@sylvainjule
Copy link
Owner

Both default and required work fine for me with Kirby 3.5. It seems that default value are handled differently when added to already existing pages, maybe that's what was at fault.

I'm closing this, please don't hesitate to reopen if it still happens.

@herrajon
Copy link
Author

Howdy Sylvain

Revisited this simple but useful plugin again. Really like the simplicity of it.

After few rounds of T&E I got the default option to work and not display an error page (error if the user selects no colour option):

In section 3.5 on the README.md for the plugin it states:

# structured colours
palette:
  type: color-palette
  default: blue
  options:
    blue:
      background: '#135fdc'
      border: '#0438c7'
    orange:
      background: '#f6917e'
      border: '#ef6a57'

This displays an Error page for me in various Kirby versions. Currently running 3.5.7.1.

But the following combination does work:

# structured colors
palette:
  type: color-palette
  default: 
    background: '#135fdc'
    border: '#0438c7'
    key: blue
  options:
    blue:
      background: '#135fdc'
      border: '#0438c7'
    orange:
      background: '#f6917e'
      border: '#ef6a57'

So in my case at least the background and border (and others if in question) attributes need to be defined with the Default along with a key value of the configured color optionn (key: blue in this case) and with one indent.

Hope this is useful.

Best,
Jón

@sylvainjule sylvainjule reopened this Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants