[html-formfu] Model::DBIC: label-style text field
Moritz Onken
onken at houseofdesign.de
Thu Dec 25 10:15:50 GMT 2008
>
> It would be so much easier if we had an element like Element::Label.
> But I have no idea how this would be implemented because it needs to
> be
> read only and has no input field.
>
> - type: Label
> name: price
>
> would be great. I could put this in a multi element and my cart is
> ready to
> go.
> But model::dbic has to ignore it if there is a param "price" with a
> value.
>
Hi,
regarding this problem I tried to create an Element::Label.
There is an attribute non_param which should remove the value from
$form->param
if set (that's what I read from the docs).
Here is a simple test (patch) which shows, that field which have this
attribute set are updated in the model anyway.
Index: t/update/has_many_repeatable.t
===================================================================
--- t/update/has_many_repeatable.t (revision 1275)
+++ t/update/has_many_repeatable.t (working copy)
@@ -72,3 +72,24 @@
is( $add[1]->address, 'new office' );
}
+my $el = $form->get_all_element({name => "name"});
+$el->non_param(1);
+{
+ $form->process( {
+ 'id' => 2,
+ 'name' => 'new new nick',
+ } );
+
+ ok( $form->submitted_and_valid );
+
+ my $row = $schema->resultset('User')->find(2);
+
+ $form->model->update($row);
+}
+
+{
+ my $user = $schema->resultset('User')->find(2);
+
+ is( $user->name, 'new nick' );
+
+}
Is this the intended behaviour?
cheers,
moritz
More information about the HTML-FormFu
mailing list