Re: [html-formfu] Patch for H::F::ObjectUtil::remove_element issue, submitted poorly :(

2009-05-30 Thread Carl Franks
2009/5/30 Mike South mso...@gmail.com:

 I had a Repeatable block which had a delete_if_true checkbox in a
 child block.  The remove_element call that gets rid of the
 delete_if_true box on an empty_row was croaking (this is because
 get_fields recurses, but remove_element doesn't).

 I submitted a patch with a test on google code, but I did the
 summary/name poorly and I didn't identify it as a bug, etc.  (First
 time using google code, I didn't realize I wouldn't be able to update
 what I submitted).  Sorry about that!

Hi Mike,

Sorry, this is the intended behaviour, and I'm not keen on changing it.
Though, you could use the following idiom to achieve what you want:

$field-parent-remove_element( $field );

Carl

___
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


Re: [html-formfu] Patch for H::F::ObjectUtil::remove_element issue, submitted poorly :(

2009-05-30 Thread Mike South
On Sat, May 30, 2009 at 3:42 PM, Carl Franks fireart...@gmail.com wrote:
 2009/5/30 Mike South mso...@gmail.com:

 I had a Repeatable block which had a delete_if_true checkbox in a
 child block.  The remove_element call that gets rid of the
 delete_if_true box on an empty_row was croaking (this is because
 get_fields recurses, but remove_element doesn't).

 I submitted a patch with a test on google code, but I did the
 summary/name poorly and I didn't identify it as a bug, etc.  (First
 time using google code, I didn't realize I wouldn't be able to update
 what I submitted).  Sorry about that!

 Hi Mike,

 Sorry, this is the intended behaviour, and I'm not keen on changing it.
 Though, you could use the following idiom to achieve what you want:

    $field-parent-remove_element( $field );

I could, but it's not my code that's dying, it's HTML::FormFu::Model::DBIC.

The way it is now, if someone puts that checkbox in a sub block, say
for formatting (there's an example of someone that tried to do this on
the list earlier, I'm not the first that's tried), DBIC croaks on it.

In other words, applying the following patch causes the test to fail:

Index: t/default_values/has_many_repeatable_delete_true.yml
===
--- t/default_values/has_many_repeatable_delete_true.yml(revision 1525)
+++ t/default_values/has_many_repeatable_delete_true.yml(working copy)
@@ -21,10 +21,12 @@
   - type: Text
 name: address

-  - type: Checkbox
-name: delete
-model_config:
-  delete_if_true: 1
+  - type: Block
+elements:
+  - type: Checkbox
+name: delete
+model_config:
+  delete_if_true: 1

   - type: Hidden
 name: count

If you intend to disallow that, I think it ought to be pointed out in
the documentation that you need to keep the Repeatable block flat.

If you want to keep non-recursion as the default behavior in
ObjectUtil, a couple of alternatives would be:

(1) Alter H::F::M::DBIC to eval the remove_element and recurse into
child blocks to handle a case like this without croaking

(2) Add a 'recurse' flag to remove_element, and use that in
H::F::M::DBIC's call (or even a remove_element_recursively method).

I would be willing to code either of those up, just let me know.

mike


 Carl

 ___
 HTML-FormFu mailing list
 HTML-FormFu@lists.scsys.co.uk
 http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


___
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu