Prevent using reserved words as field handles #3989
Merged
+54
−4
Conversation
| $values = array_merge($request->values, $fields->values()->all()); | ||
|
|
||
| return $values; | ||
| } | ||
|
|
||
| protected function blueprint($blueprint) | ||
| { | ||
| $reserverd = [ |
michaelr0
Jul 15, 2021
•
Contributor
$reserverd I assume is a typo.
$reserverd I assume is a typo.
| @@ -76,6 +93,7 @@ protected function blueprint($blueprint) | |||
| 'display' => __('Handle'), | |||
| 'instructions' => __('statamic::messages.fields_handle_instructions'), | |||
| 'type' => 'text', | |||
| 'validate' => 'required|not_in:'.join(',', $reserverd), | |||
michaelr0
Jul 15, 2021
•
Contributor
$reserverd I assume is a typo.
$reserverd I assume is a typo.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.



This is an implementation for idea #46 and a partial fix for #3956.
It adds the mechanics for checking for reserved words and notifying the user in a meaningful way. The list of reserved words can (and probably should) be extended in the future of course.