File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class ContactForm extends Form
4141 {
4242 // Use this function to crossfields validation
4343 //
44- // You can use $this->addError($message, $field ) to add error messages to specific fields.
44+ // You can use $this->addError($message, $field_name ) to add error messages to specific fields.
4545 // Or just throw a ValidationError Exception.
4646 }
4747}
Original file line number Diff line number Diff line change @@ -33,16 +33,21 @@ public function setChoices(array $choices)
3333 $ this ->widget ->setChoices ($ choices );
3434 }
3535
36+ public function isEmpty ($ value )
37+ {
38+ return empty ($ value ) && $ value != "0 " ;
39+ }
40+
3641 public function toNative ($ value )
3742 {
38- return !empty ($ value ) ? (string ) $ value : '' ;
43+ return !$ this -> isEmpty ($ value ) ? (string ) $ value : '' ;
3944 }
4045
4146 public function validate ($ value )
4247 {
4348 parent ::validate ($ value );
4449
45- if (empty ($ value ) || !array_key_exists ($ value , $ this ->choices )) {
50+ if ($ this -> isEmpty ($ value ) || !array_key_exists ($ value , $ this ->choices )) {
4651 $ message = Formatter::format ($ this ->error_messages ['invalid ' ], array (
4752 'choice ' => $ value
4853 ));
You can’t perform that action at this time.
0 commit comments