-
Notifications
You must be signed in to change notification settings - Fork 819
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
BUG: Added setExcludedID() to exclude a certain record from uniqueness checking. #1740
Conversation
Travis build failure due to github unavailability, not code. |
* Exclude the provided ID in the restrictedTable from uniqueness checking. | ||
* @var [integer] | ||
*/ | ||
$this->excludedID = (int)$excludedID; |
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.
phpdoc should be placed before function declaration
Actually, can we change this to use DataList instead of restrictedTable etc? Then you can set the list, with your own exclusions applied (via |
So there should be a |
…apphire into 1399-ajaxutf-excludeid Conflicts: forms/AjaxUniqueTextField.php
OK so this is the new implementation using DataList. Because the ajaxUTF has to add filters / excludes for the current form's submitted values but before validating, I implemented setting a callback (setListProvider) which gets called at the start of the validate() method. The change to the __constructor is simply that $restrictedField and $restrictedTable are now optional. Two things:
|
Why not just let |
* | ||
* @param DataList $list | ||
*/ | ||
public function setList(DataList $list) { |
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.
Should accept any SS_List
, not just data lists. Also, the API docs aren't very clear - the description isn't great, and the example isn't really necessary.
Also, please squash this to a single commit and remove the merge commits (with |
$this->validateURL = $validationURL; | ||
|
||
$this->restrictedRegex = $restrictedRegex; | ||
|
||
parent::__construct($name, $title, $value); | ||
parent::__construct($name, $title, $value, $maxLength); |
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.
$maxLength definitely doesn't need to be a new required arg. It shouldn't be a constructor arg at all, we're trying to reduce those rather than add new ones. Can be a standard accessor.
EDIT: OK, this is the parent call ... and TextField has this argument as well (for legacy reasons). Good change.
Hello Sander, can you please fix the conventions and Andrew's comments on |
@chillu didn't we delete this class from master? Any use changing it if it's deprecated. |
Yeah we have removed it from master in #1974. This pull request and discussion is "older", and targets 3.1. I'm not too fussed with merging it for the sake of making the field slightly less useless in 3.1, but you're right we shouldn't spend much energy on the pull request. Sander, maybe you want to take on this field as your own module? |
Issues haven't been addressed in almost a year. Closing. |
As per issue #1399.
This pull request allows end-users to edit records that contain AjaxUniqueTextFields. Prior to this validation always fails when saving and updated record when AjaxUniqueTextFields are not updated. This is because the validation find the current record in the database.
With the patch, developers can use the new $ajaxutf->setExcludedID($this->ID) to exclude the current record from the uniqueness check.