Skip to content
Browse files

change 'missing' to attribute and document

  • Loading branch information...
1 parent 8aebb57 commit 819d5c8d9e32d36755dc817caf90dbdf3442f921 @gshank committed Jun 21, 2012
View
5 Changes
@@ -1,3 +1,8 @@
+ Re-write elimination of PrimaryKey field from repeatable value,
+ add 'no_value_if_empty' attribute
+ Fix bug with labels '0' not being displayed
+ Change 'missing' to an attribute.
+
0.40012 Fri Jun 15, 2012
Bug cloning merging repeatable instances; form reference garbage collected
Doc typos
View
7 lib/HTML/FormHandler/Field.pm
@@ -581,16 +581,11 @@ has 'result' => (
'_set_input', '_clear_input', '_set_value', '_clear_value',
'errors', 'all_errors', '_push_errors', 'num_errors', 'has_errors',
'clear_errors', 'validated', 'add_warning', 'all_warnings', 'num_warnings',
- 'has_warnings', 'warnings',
+ 'has_warnings', 'warnings', 'missing',
],
);
has '_pin_result' => ( is => 'ro', reader => '_get_pin_result', writer => '_set_pin_result' );
-sub missing {
- my $self = shift;
- return $self->required && $self->validated && ( !$self->has_input || !$self->input_defined );
-}
-
sub has_input {
my $self = shift;
return unless $self->has_result;
View
2 lib/HTML/FormHandler/Field/Result.pm
@@ -23,6 +23,8 @@ has 'field_def' => (
writer => '_set_field_def',
);
+has 'missing' => ( is => 'rw', isa => 'Bool' );
+
sub fif {
my $self = shift;
return $self->field_def->fif($self);
View
1 lib/HTML/FormHandler/Manual/Reference.pod
@@ -157,6 +157,7 @@ L<HTML::FormHandler::Render::Simple>, and in the individual field classes.
validate_method Validation coderef, or 'validate_$fieldname' in form (default)
required Field is required
required_when Takes a hashref of field name keys and values
+ missing Flag set when a 'required' or 'required_when' fails
maxlength Text fields. Validated.
minlength Text fields. Used in validation
range_start Range start for number fields
View
5 lib/HTML/FormHandler/Manual/Validation.pod
@@ -38,6 +38,11 @@ There is also the 'required_when' attribute, which works the same way as the
has_field 'fee' => ( required_when => { 'fie' => 2 } );
+When a 'required' or 'required_when' check fails, a 'missing' flag is set
+in the result:
+
+ if ( $field->missing ) { ... }
+
=head2 range_start, range_end
Starting and ending range for number fields.
View
1 lib/HTML/FormHandler/Validate.pm
@@ -64,6 +64,7 @@ sub validate_field {
if ( ( $field->required ||
( $field->has_required_when && $field->match_when($field->required_when) ) ) &&
( !$field->has_input || !$field->input_defined ) ) {
+ $field->missing(1);
$field->add_error( $field->get_message('required'), $field->loc_label );
if( $field->has_input ) {
$field->not_nullable ? $field->_set_value($field->input) : $field->_set_value(undef);

0 comments on commit 819d5c8

Please sign in to comment.
Something went wrong with that request. Please try again.