[html-formfu] Modifying a form field.

Leanan Sidhe the.leanan.sidhe at gmail.com
Wed Apr 1 22:13:45 BST 2009


I have heard that TIMTOWTDI, but the only suggestions I've seen were in
regards to password fields and using DBIx::Class::DigestColumns.  I need to
do some mathematical conversions on columns before the data is put into the
database.  I'm trying to do it this way:



  my $elements_to_convert =3D $form->get_all_elements({ type =3D> 'Text'});

  foreach my $element (@{$elements_to_convert}) {
    if ($element->attributes->{'class'} =3D~ /I-want-to-convert-this/){
      my $nested_name =3D $element->nested_name;
      my $field_value =3D $form->param_value($nested_name);
      $element->default(($field_value * $conversion));
    }
  }

However, nothing is working.  I've tried $element->default($my_new_value),
$form->default_values($nested_name =3D> $my_new_value),
$form->default_values({$nested_name =3D> $my_new_value}) and
$form->add_valid($nested_name, $my_new_value}).  None of these seemed to
work.

Is add_valid only for adding new fields?  The doc says "The provided value
replaces any current value for the named field." which suggests to me that
if I have a field foo, $form->add_valid(foo, $new_value) should work.  But
then I saw this in HTML::FormFu::Model::DBIC: "add_valid works for
fieldnames that don't exist in the form." Which suggest that it only works
to add new valid fields.  I'm a little confused by this.

Ideas?  Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20090401/72=
1372ac/attachment.htm


More information about the HTML-FormFu mailing list