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

Image field types in a collection of sets should by default return empty #1378

Closed
nealmarques opened this issue May 15, 2020 · 10 comments · Fixed by #1419
Closed

Image field types in a collection of sets should by default return empty #1378

nealmarques opened this issue May 15, 2020 · 10 comments · Fixed by #1419
Assignees

Comments

@nealmarques
Copy link

nealmarques commented May 15, 2020

Empty image field types that are part of set in a collection are returning '/files/' when empty. I'm expecting an empty string. I'm having to check for '/files/' instead of using "is empty" condition.

| Relevant Bolt Version | version4.0.0 RC 17
| Install type | Composer install
| BC Break | yes/no
| PHP version | 7.3
| Web server | Built-in

@nealmarques nealmarques changed the title Image File types in a collection of sets should by default return empty Image field types in a collection of sets should by default return empty May 15, 2020
@bobdenotter
Copy link
Member

@nealmarques I couldn't reproduce this, just yet.. Could you post the contenttype from contenttypes.yaml?

@nealmarques
Copy link
Author

contenttypes.yaml.txt

@I-Valchev
Copy link
Member

@nealmarques I am not able to reproduce this yet as well. Using the contenttypes.yaml that you provided, when I create a row with all fields empty, and dump the row_background_image value, I get:

array:7 [▼
  "filename" => ""
  "path" => ""
  "media" => ""
  "thumbnail" => ""
  "fieldname" => "row_background_image"
  "alt" => ""
  "url" => ""
]

The image value is an array with filename, path, media, thumbnail, fieldname and url. Can you provide the output you're getting for each of those, so that I can see which one exactly contains /files/?

@nealmarques
Copy link
Author

When I dump out row_background_image I don't get such a clean list of values,
Screenshot 2020-05-19 at 15 35 50
To be honest, I can't even find the array that lists out the row_background_image.

However,
I'm looping through the rows in the section, and if do the following:

{{dump(row.row_background_image == '/files/')}}. I'll get true
{{dump(row.row_background_image is empy)}}. I'll get false.

And this is on an empty page with just an empty row defined.

@nealmarques
Copy link
Author

I should also mention that I'm just using sqllite.

@I-Valchev
Copy link
Member

Right, I see.
@nealmarques can you try

{% dump(row_background_image.value) %}

This should output the array like it did in my earlier comment. Make sure that you dump that in a place where row_background_image is defined, of course :-)

@nealmarques
Copy link
Author

With the .value I can see that filename is empty, as expected. The question is, should I be using .value.filename to see if its empty; or should it be expected that "row_background_image is empty" will return true if the filename is empty.

@bobdenotter
Copy link
Member

@nealmarques I think it'd be really nice if {% if record.row_background_image %} would work that way, but i don't think we can make it work that way. Under the hood, row_background_image is an Object for the field, so it'll evaluate to the object. Even if there's no image set, it's still a valid Field Object. Same goes for is empty: The field has attributes, regardless of an actual image being set.

@nealmarques
Copy link
Author

Okay.

@I-Valchev
Copy link
Member

let's just keep this open for a bit: we might be able to pull it off with the countable interface.

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

Successfully merging a pull request may close this issue.

3 participants