Yeah, I was hoping I wouldn't have to go that route. Ultimately if I can't figure this out I'll have to, but it seems unreasonable to not be able to delete one element from a form definition. | [reply] |
Yeah, I was hoping I wouldn't have to go that route. Ultimately if I can't figure this out I'll have to, but it seems unreasonable to not be able to delete one element from a form definition.
Why not?
To my mind, each screen is a different form, anything else is too complicated and reserved for client side javascript (ajax) manipulations :) I guess its a matter of perspective.
I'm not really up on HTML::FormFu::Manual::BasicConcepts, but remove_elements does appear to work
#!/usr/bin/perl --
use strict;
use warnings;
use HTML::FormFu;
use YAML::XS qw( Load );
Main( @ARGV );
exit( 0 );
sub Main {
Fain();
print "\n", '#' x 33 , "\n";
Fain( { dependOnMe => "if i'm not here, remove fooRadiogroup" } );
}
sub Fain {
my $cgi = shift;
my $form = HTML::FormFu->new;
my $data = Load(<<'__YAML__');
---
elements:
- type: Text
name: foo
- type: Text
name: dependOnMe
- type: Radiogroup
name: fooRadiogroup
options:
- value: 1
label: 'First'
attributes:
myattr: 'escape&attr'
label_attributes:
myattr: 'escape&label'
container_attributes:
myattr: 'escape&container'
- value: 2
label: 'Second'
attributes_xml:
myattr: 'noescape&'
__YAML__
$form->populate($data);
$form->process( $cgi );
if( not $form->valid('dependOnMe') ){
my $pariah = $form->get_field( name => 'fooRadiogroup', type =
+> 'Radiogroup' ) ;
$form->remove_element( $pariah );
}
print $form;
}
__END__
| [reply] [d/l] |