Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Quotation marks in text field inside structure are removed. #892

Closed
LCD344 opened this issue Jul 16, 2016 · 4 comments
Closed

Quotation marks in text field inside structure are removed. #892

LCD344 opened this issue Jul 16, 2016 · 4 comments
Labels

Comments

@LCD344
Copy link

LCD344 commented Jul 16, 2016

I'm making a bootstrap carousel with quotes.

In the panel it looks like a structure with a textarea field for the quote and a text field.

label: Success Stories
type:  structure
entry: >
  {{name}} 
fields:
  name:
    label: Full Name
    type:  input
  quote:
    label: Quote
    type:  textarea`

But when I save a a text between quotation marks, the quotation sometimes marks just disappear - not in all cases, but in some of them. the only one I could say happens regularly is the first entry.

@texnixe
Copy link

texnixe commented Jul 16, 2016

That's probably due to how textarea fields are saved in the content file for a structure field. I'd just save the text without any quotation marks and add them via CSS. That gives you absolute control over how your quotes look and you do not depend on the quotes actually being added to the text.

@LCD344
Copy link
Author

LCD344 commented Jul 16, 2016

Yea, I debugged that far... and I found a workaround. but this should still be flagged. In case somebody in the future wants to make something where there are quotation marks only around certain texts...

@lukasbestle
Copy link
Member

I tracked down where this comes from with the following reduced test case:

$data = [
    [
        'name' => 'Lorem ipsum',
        'quote' => 'Dolor sit amet.'
    ],
    [
        'name' => 'Consetetur sadipscing',
        'quote' => '"Elitr sed diam nonumy eirmod."'
    ]
];

echo Spyc::YAMLDump($data, false, false, true);

It is basically exactly what Kirby does internally, but only using the Spyc YAML library that Kirby uses.

The result is:

- 
  name: Lorem ipsum
  quote: Dolor sit amet.
- 
  name: Consetetur sadipscing
  quote: "Elitr sed diam nonumy eirmod."

Note the quotes in the result. If we run that through the YAML parser again, we get this:

Array
(
    [0] => Array
        (
            [name] => Lorem ipsum
            [quote] => Dolor sit amet.
        )

    [1] => Array
        (
            [name] => Consetetur sadipscing
            [quote] => Elitr sed diam nonumy eirmod.
        )

)

Note that the quotes are missing. The reason is that those quotes have a meaning in YAML as delimiters for string values. I think this is a bug in Spyc, see mustangostang/spyc#53.

@LCD344
Copy link
Author

LCD344 commented Jul 17, 2016

Thanks for taking it up with them.
What is weird for me is that sometimes the quotation marks do stay around the string.

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

No branches or pull requests

4 participants