File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -732,9 +732,16 @@ protected function db_insert_validation()
732732 foreach ($ add_fields as $ add_field )
733733 {
734734 $ field_name = $ add_field ->field_name ;
735- if (!isset ($ this ->validation_rules [$ field_name ]) && in_array ( $ field_name , $ required_fields ) )
736- {
737- $ this ->set_rules ( $ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
735+
736+ // Workaround as Codeigniter set_rules has a bug with array and doesn't work with required fields.
737+ // We are basically doing the check here!
738+ if (array_key_exists ($ field_name , $ this ->relation_n_n ) && in_array ($ field_name , $ required_fields )) {
739+ if (!array_key_exists ($ field_name , $ _POST )) {
740+ // This will always throw an error!
741+ $ this ->set_rules ($ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
742+ }
743+ } else if (!isset ($ this ->validation_rules [$ field_name ]) && in_array ( $ field_name , $ required_fields ) ) {
744+ $ this ->set_rules ($ field_name , $ field_types [$ field_name ]->display_as , 'required ' );
738745 }
739746 }
740747 }
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
4+ - #38: required_fields doesn't work for relation_n_n fields
55v 1.6.2
66 - #442: Searching in grid with value 0 is not working
77 - #458: Updated Lithuanian language by @dgvirtual
You can’t perform that action at this time.
0 commit comments