Attached is second patch to support the minimum Range, this patch is for
the case when the content is not yet in the database and Model::DBIC
doesn't fill the contents. It is for HTML::FormFu::Element::Repeatable and
against the current version in SVN.
Usage is the same as in the Jan22 patch, for example:
- type: Hidden
name: article_image_count
constraints:
- type: Range
max: 15
min: 10
- type: Repeatable
counter_name: article_image_count
Could someone commit this patch and the Jan22 patch and/or give me commit
access to the svn? I've been using them in production for a while and they
appear to work ok.
Okko
On Thu, 22 Jan 2009, Oskari 'Okko' Ojala wrote:
please find attached a patch to
HTML-FormFu-Model-DBIC/lib/HTML/FormFu/Model/DBIC.pm. It is against revision
1293, the most recent in svn. I would appreciate if someone could commit it
to the svn.
It contains the following improvements:
-It is possible to specify minimum in the Repeatable's count field's Range
constraint, complementing the earlier implementation of maximum.
--
Oskari "Okko" Ojala
--- Repeatable.pm 2009-02-06 14:33:19.000000000 +0200
+++ Repeatable.pm 2009-02-06 16:56:26.000000000 +0200
@@ -144,6 +144,14 @@
if ( defined $input && $input =~ /^[1-9][0-9]*\z/ ) {
$count = $input;
}
+
+ # Determine minimum count
+ my $minimum_count;
+ my $field = $form->get_field($self->counter_name);
+ if (defined($field) && defined (my $range =
$field->get_constraint({type => 'Range'}))) {
+ $minimum_count = $range->{'minimum'} || 0;
+ }
+ $count = $minimum_count if (defined($minimum_count) &&
$count<$minimum_count);
}
if ( !$self->_original_elements ) {
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu