Skip to content

Commit

Permalink
Fix category dependent required field validation (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
obiPlabon authored Nov 22, 2023
1 parent 8e0be4c commit fdd9ae4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/classes/class-add-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public static function is_field_submission_empty( $field, $posted_data ) {
public static function validate_field( $field, $posted_data ) {
$should_validate = (bool) apply_filters( 'atbdp_add_listing_form_validation_logic', true, $field->get_props(), $posted_data );

if ( $field->is_category_only() && ! in_array( $field->get_assigned_category(), self::$selected_categories, true ) ) {
if ( is_null( self::$selected_categories ) || ( $field->is_category_only() && ! in_array( $field->get_assigned_category(), self::$selected_categories, true ) ) ) {
$should_validate = false;
}

Expand Down
4 changes: 3 additions & 1 deletion includes/directorist-directory-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function directorist_get_listing_form_field( $directory_id, $field_key = '' ) {
return array();
}

return directorist_get_listing_form_fields( $directory_id )[ $field_key ] ?: array();
$form_fields = directorist_get_listing_form_fields( $directory_id );

return empty( $form_fields[ $field_key ] ) ? array() : $form_fields[ $field_key ];
}

function directorist_get_listing_form_category_field( int $directory_id ) {
Expand Down

0 comments on commit fdd9ae4

Please sign in to comment.