alleyinteractive / alleyinteractive/wordpress-fieldmanager
Term form validation
- Ngôn ngữ chính
- PHP
- Star
- 563
- Fork
- 99
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Term form validation is broken, because how Core is doing the submission in term list ( add form ) page.
jQuery Validation apparently [should hook](https://github.com/jzaefferer/jquery-validation/blob/master/src/core.js#L28) on `click` event for `:submit` input within the form, but somehow that does not get bound ( inspecting `$form.data('events').click` didn't show any entry from jQuery.validation ), and I didn't trace the reason for that.
**Steps to reproduce**
- Add a select or a textarea input in term
- Mark it as required, using either/both `required` and `validation_rules` params ( a bit confused on why `required` isn't working but `validation_rules` is for term edit pages, which works fine ).
- Submit the form without filling the new inputs
**Expected**
- Form is not submitted and error messages is present
**Actual**
- No errors, and the form is submitted
**Proposed Solution**
- Overload the validateForm function to execute jQuery validation first. Something in the lines of
``` js
let body = $( 'body' );
if ( body.hasClass( 'edit-tags-php' ) || body.hasClass( 'term-php' ) ) {
if ( 'undefined' !== typeof validateForm ) {
var wpValidateForm = validateForm;
validateForm = function( form ) {
return ! ( ! wpValidateForm( form ) || ( 'undefined' !== typeof $( form ).data().validator && ! $( form ).data().validator.form() ) );
};
}
}
```
**Note**
- This is a bit related to this Trac ticket: https://core.trac.wordpress.org/ticket/37540, so would not have been discovered without Core failing in that ( because I'm mainly using the required validation rule only ). But would've still be an issue for other validation rules ( which validateForm does not handle ).
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.