Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

[3.x] Limit when values of a select is an entity#7742

Merged
JarJak merged 5 commits intobolt:3.6from
romulo1984:romulo1984-patch-1
Feb 18, 2019
Merged

[3.x] Limit when values of a select is an entity#7742
JarJak merged 5 commits intobolt:3.6from
romulo1984:romulo1984-patch-1

Conversation

@romulo1984
Copy link
Copy Markdown
Contributor

The use of the limit, in a field of type select, only happens when the values are of type Yaml. This small change makes it possible to use threshold when the value is an entity.

A major problem that can occur with the lack of this feature is when a filter is not used and returns many results. Because there is no limit, the query may break the application and return a fatal error.

Usage

...
  fields:
    breaking_news:
      type: select
      values: entries/id,title
      keys: slug
      sort: -id
      limit: 10

If the property is not specified, the default limit of 500 is considered.

@JarJak
Copy link
Copy Markdown
Member

JarJak commented Feb 14, 2019

Limit is for maximum number of options to be selected, not for limiting number of choices.
However this issue could be fixed with using autosuggestion AND limit, so after entering more chars you can get what you need.

@romulo1984
Copy link
Copy Markdown
Contributor Author

romulo1984 commented Feb 14, 2019

@JarJak, I think you got the wrong one or the application works incorrectly. For yaml values, this limit is applied to limit the number of available options and not the number of selections.

private function getYamlValues(Bag $field)
{
$values = array_slice($field->get('values', []), 0, $field->get('limit'), true);
if ($field->get('sortable')) {
asort($values, SORT_REGULAR);
}
return $values;
}

@JarJak
Copy link
Copy Markdown
Member

JarJak commented Feb 14, 2019

Use limit to limit the amount of items. Note that the default is 500, so if you have a long list, and you need to show them all to the user, raise this limit.

So yeah you are right, just the docs are not clear here :/

@JarJak
Copy link
Copy Markdown
Member

JarJak commented Feb 15, 2019

Looks like tests need an update too :)

@romulo1984
Copy link
Copy Markdown
Contributor Author

@JarJak Up-to-date tests.

@JarJak
Copy link
Copy Markdown
Member

JarJak commented Feb 18, 2019

Thank you @romulo1984 !

@JarJak JarJak merged commit 50f861d into bolt:3.6 Feb 18, 2019
@romulo1984
Copy link
Copy Markdown
Contributor Author

Thank you, @JarJak

When is the next release expected to go out?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants