-
-
Notifications
You must be signed in to change notification settings - Fork 22
Undefined index 0 fix with Turkish localizations and required flag added #40
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
base: main
Are you sure you want to change the base?
Conversation
andreia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @onursahindur :)
Thank you so much for taking the time to work on this, and apologies for the delay in getting back to you!
The "Undefined index 0" fix and the translations look great! 🎉
Regarding the required() option added to the Google Autocomplete select field: the select field itself is only used to search the Google API and populate the fields specified in the withFields() method. These are the fields where required() validation can be applied.
The select field isn’t saved to the database currently (as you can see with ->dehydrated(false) used here) only the fields provided in withFields() are persisted.
Do you have a specific use case where making the select field itself required would be helpful?
Hello, thanks! The fields under That’s why having the |
|
@onursahindur Ah, that makes perfect sense 🙂 Thank you for explaining your use case! I’ll run some tests on my side just to double-check everything is working smoothly. If you’d like, you could also create a separate PR for the ‘Undefined index 0’ fix and another one for the 'Turkish localizations' so I can merge those right away. That way, we can keep this PR focused just on the required option. |
|
@onursahindur I was thinking about how to solve the issue when using public function getIsRequired(string $operation, ?Get $get = null): bool
{
// If the user hasn't explicitly set the field as required, return false
if (!$this->evaluate($this->isRequired)) {
return false;
}
// If this is an edit operation and we have access to form data
if ($operation === 'edit' && $get !== null) {
// Check if any of the child fields have values
foreach ($this->getWithFields() as $field) {
$fieldValue = $get($field->getName());
// If any child field has a non-empty value, consider the requirement satisfied
if (!empty($fieldValue)) {
return false;
}
}
}
// For create operations or when no child fields have values, return the original required state
return $this->evaluate($this->isRequired);
}And change the ->required(function (string $operation, Get $get) {
return $this->getIsRequired($operation, $get);
})So: Create operations:
Edit operations:
What do you think? |
No description provided.