File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -825,10 +825,19 @@ protected function db_update_validation()
825825 foreach ($ edit_fields as $ edit_field )
826826 {
827827 $ field_name = $ edit_field ->field_name ;
828- if (!isset ($ this ->validation_rules [$ field_name ]) && in_array ( $ field_name , $ required_fields ) )
829- {
830- $ this ->set_rules ( $ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
828+
829+ // Workaround as Codeigniter set_rules has a bug with array and doesn't work with required fields.
830+ // We are basically doing the check here!
831+ if (array_key_exists ($ field_name , $ this ->relation_n_n ) && in_array ($ field_name , $ required_fields )) {
832+ if (!array_key_exists ($ field_name , $ _POST )) {
833+ // This will always throw an error!
834+ $ this ->set_rules ($ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
835+ }
836+ } else if (!isset ($ this ->validation_rules [$ field_name ]) && in_array ( $ field_name , $ required_fields ) ) {
837+ $ this ->set_rules ($ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
831838 }
839+
840+
832841 }
833842 }
834843
Original file line number Diff line number Diff line change 11v1.6.3
22 - #465: Translation for Spanish Uruguay by @mlopezcoria
33 - #468: Remove PHP 7.3 warnings
4+ - #38: required_field doesn't work for relation_n_n fields
45v 1.6.2
56 - #442: Searching in grid with value 0 is not working
67 - #458: Updated Lithuanian language by @dgvirtual
You can’t perform that action at this time.
0 commit comments