[html-formfu] Many-to-Many Relationships and Repeatables
Is it possible to use a Repeatable containing Select elements to edit/add rows in a table linked by a many-to-many relationship? All I see in the documentation is instructions on how to use Checkbox or Select elements with multiple selection enabled. Thanks, Greg Coates Coatesoft ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Select elements inside Repeatables
Updating to HTML-FormFu-Model-DBIC 0.04003 fixed this problem. However, that introduced a new issue. I'm using some custom, calculated fields in my DBIx::Class setup. Here's the relevant part of the schema definition: package Coatesoft::PBP::Schema::DB::Contacts; use strict; use warnings; use base 'DBIx::Class'; __PACKAGE__-load_components(Core); __PACKAGE__-table(contacts); __PACKAGE__-add_columns( ctc_id, { data_type = bigint, default_value = nextval('contacts_ctc_id_seq'::regclass), is_nullable = 0, size = 8, }, [ ... SNIP ... ] sub ctc_common_name { my $self = shift; if ($self-ctc_is_company()) { return $self-ctc_last_name(); } else { return $self-ctc_first_name() . . $self-ctc_last_name(); } } I'm using the custom column in the form like so: elements: - type: Select name: ivc_vendor label: Vendor model_config: resultset: Contacts id_column: ctc_id label_column: ctc_common_name Before, this worked fine. Now I get this error: BIx::Class::Row::get_column(): No such column 'ctc_common_name' at /usr/lib/perl5/site_perl/5.8.5/HTML/FormFu/Model/DBIC.pm line 110 Greg Carl Franks wrote: 2009/5/12 Greg Coates g...@coatesoft.com: It looks like this has been undone in the new release from CPAN (0.04002). I updated, and all of the data in my 'selects' disappeared. Have you also updated to the latest CPAN release of HTML-FormFu-Model-DBIC ? I believe there was a change in that, that was also required. Cheers, 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
Re: [html-formfu] Repeatable displays every row in table (bug?)
This fixed the problem, but it brings up another issue. From the DBIx::Class::Resultset documentation: | Note: find_or_new is probably not what you want when creating a | new row in a table that uses primary keys supplied by the | database. Passing in a primary key column with a value of undef | will cause find to attempt to search for a row with a value of | NULL. That's exactly what's happening to me, and it causes the insert that follows to fail. I'm not sure where to go with this. Write a test that fails? Somethings else? Greg Greg Coates wrote: Yep, that solved it for me too. Greg Ascii King wrote: I had this same problem back in this thread http://lists.scsys.co.uk/pipermail/html-formfu/2009-March/001884.html the answer was how I was calling the new record. I eeded to use find_or_new to call a new record. my $book = $c-model('DB::MyTable')-find_or_new({ id = $id }); Mario Minati wrote: OK. Let me try again, then. I have a form that is used to display invoices from a table called 'invoices'. It contains a Repeatable that is used to display the individual lines for those invoices. These lines come from a table called 'invoice_items'. When the form is used on an existing record, all is well. However, when I use the form to create a new record, I have a problem. Instead of the Repeatable being blank, every row from the 'invoice_items' table is displayed. Greg ___ 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
[html-formfu] SVN Checkin access
I've got a couple of new deflators/inflators that I've written and would like to add to svn. I looked around the FormFu website, and I can't seem to find how permission is granted for such things. Do new modules need to be submitted to Carl? Or can someone grant access to SVN? Thanks, Greg ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Re: Repeatable save problems
Yes, I did take out that call to process(). Same problem. Greg Lance A. Brown wrote: Greg Coates said the following on 4/30/2009 6:31 PM: Bumping this. Everything suggested as possible problems ended up being okay. Does anyone have any ideas? Carl? Did you try taking that call to $form-process() out of the submitted_and_valid section? --[Lance] ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Repeatable save problems
Bumping this. Everything suggested as possible problems ended up being okay. Does anyone have any ideas? Carl? Thanks, Greg Greg Coates wrote: I have a form that contains a repeatable block that I'm using with Catalyst. For some reason, the items in the child table aren't getting saved along with the rest of the data. I've scoured the documentation, and as far as I can tell, I have all of the necessary bits in place. Here's the repeatable block from the form definition: - type: Repeatable name: invoice_lines nested_name: invoice_items counter_name: line_cnt auto_id: %n attributes: class: data_row invoice_item elements: - type: Hidden name: ivi_id - type: Block attributes: class: ivi_desc elements: - type: Text name: ivi_desc size: 75 - type: Block attributes: class: ivi_unit_price numeric elements: - type: Text name: ivi_unit_price size: 8 - type: Block attributes: class: ivi_quantity numeric elements: - type: Text name: ivi_quantity size: 5 - type: Block attributes: class: ivi_total_price numeric elements: - type: +Coatesoft::FormFu::Element::DataLabel name: ivi_total_price - type: Block attributes: class: ivi_account elements: - type: Select name: ivi_account model_config: resultset: Accounts id_column: acc_id label_column: acc_title - type: Block attributes: class: ivi_item elements: - type: Select name: ivi_item empty_first: 1 empty_first_label: no inventory item model_config: resultset: Items id_column: itm_id label_column: itm_description - type: Block attributes: class: ivi_tax_type elements: - type: Select name: ivi_tax_type empty_first: 1 empty_first_label: no tax model_config: resultset: Taxes id_column: tax_id label_column: tax_desc - type: Block attributes: class: ivi_memo elements: - type: Text name: ivi_memo size: 100 And here's the relevant part of my Catalyst controller: sub edit :Local :FormConfig('invoices/edit_invoice.yml') { my ($self, $c, $ivc_id) = @_; if ($c-request-param('cancel')) { $c-response-redirect($c-uri_for(/invoices)); $c-detach(); } my $invoice = ($ivc_id) ? $c-model('DB::Invoices')-find($ivc_id) : $c-model('DB::Invoices')-new_result({}); my $form = $c-stash-{form}; if ($form-submitted_and_valid()) { $form-process(); $form-model-update($invoice); if (! $c-request-param('draft')) { # Save to accounts } $c-response-redirect($c-uri_for(/invoices)); $c-detach(); } } Does anyone see anything that I might be missing? Is the fact that my form elements are inside Block elements causing problems? Thanks, Greg Coates Coatesoft ___ 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
Re: [html-formfu] Feature request: Repeatable delete from model behavior
I hadn't thought of the concurrency issue. Therefore, I think that your javascript field setting/hiding method is the way to go here. Thanks for the insight. Greg Charlie Garrison wrote: Good afternoon, On 27/04/09 at 5:54 PM -0700, Greg Coates g...@coatesoft.com wrote: As far as I can tell from the documentation, the only way that a row can be deleted from the model (database) when using a Repeatable is by using the 'delete_if_true' attribute along with a checkbox. There's no way to automatically update the model if rows are removed from the Repeatable using javascript. Why not just use javascript to set the field assigned to 'delete_if_true'? Make it a hidden field and submit it with the form. And the javascript doesn't have to delete the row, just set it to display:none; and set the delete_if_true field. That way seems easier ( safer?) than changing HTML::FF model behaviour. It would be really great if rows could be deleted from the model if they are no longer present in the Repeatable. What if second user adds a row/record while first user has page open (row doesn't exist). First user submits form, which doesn't have the newly added row so the new row gets deleted. I doubt that is intended result. My AU$0.03. Charlie ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
[html-formfu] Feature request: Repeatable delete from model behavior
As far as I can tell from the documentation, the only way that a row can be deleted from the model (database) when using a Repeatable is by using the 'delete_if_true' attribute along with a checkbox. There's no way to automatically update the model if rows are removed from the Repeatable using javascript. It would be really great if rows could be deleted from the model if they are no longer present in the Repeatable. Is this feasible without ridiculous amounts of work. I'd be willing to tackle this myself, but I'm afraid I have a long way to go in order to come up to speed with the FormFu internals. Greg ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Many-to-many and Checkboxgroup: Getting a string of errors
Moritz Onken wrote: Are you running the latest versions of FormFu and Model::DBIC? Have a look at the docs: http://search.cpan.org/~cfranks/HTML-FormFu-Model-DBIC/lib/HTML/FormFu/Model/DBIC.pm#options_from_model I cannot see a default_column you are using. This piece of the documentation is where I'm getting the default_column option. http://search.cpan.org/~cfranks/HTML-FormFu-Model-DBIC-0.03007/lib/HTML/FormFu/Model/DBIC.pm#many_to_many_selection Greg ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
[html-formfu] Format changes between model and view
I have a situation where I'm storing a value in the database as a decimal (e.g. .07250). However, I want the user to be able to enter and view the value as a percentage (e.g. 7.250). Would a callback Transformer be the proper way to handle this? Thanks, Greg ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Possible bug - Submit element when forms have errors
Carl Franks wrote: 2009/2/18 on...@houseofdesign.de: On Tue, 17 Feb 2009 15:30:36 -0800, Greg Coates g...@coatesoft.com wrote: I think I might have found a bug. I have HTML::FormFu version 0.03007 installed. Here's what's happening. I created a form that ends with the following 3 submit buttons: --- - type: Submit name: submit value: Save for Later - type: Submit name: submit value: Finish - type: Submit name: submit value: Cancel These display as expected. However, if the form is submitted, contains errors, and then is re-displayed, the buttons all contain the same text. Here's the HTML that is generated: input name=submit type=submit value=Save for Later / input name=submit type=submit value=Save for Later / input name=submit type=submit value=Save for Later / All the values get set to the same value for some reason. Greg Coates I think this is not a bug. How should FormFu distinguish between those fields if they have the same name? You're correct that it'd be better for the different submit buttons to have different names. However, there may be an argument that a button's rendered value shouldn't be affected by any submitted value. Greg, if your form were changed to something like this: --- - type: Submit name: save value: Save for Later - type: Submit name: finish value: Finish - type: Submit name: cancel value: Cancel Then your code would change from checking the submitted value, to checking which name was sent: if ( $form-param('save') ) { } elsif ( $form-param('finish') ) { } # etc... This works because browsers only submit a name=value pair for the submit value that's clicked, and not for any other that wasn't clicked. So, in summary, this may be a bug - but before saying I'll accept a patch, I'd prefer to give a time for anyone to speak up if they think 'fixing' it could have unfortunate consequences. Carl ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu I have written some forms with different names for the submit buttons. Then, however, the form doesn't return true for 'submitted_and_valid' for the second button. (i.e. the 'Finish' button in our example.) I haven't found a way to mark more than button as the submit button using the 'indicator' attribute. Am I incorrect in this? Thanks, Greg ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Re: [html-formfu] Possible bug - Submit element when forms have errors
I went back to the documentation and took a look at this. What if the 'indicator' method were changed to accept an array in addition to a scalar. That way, more than one Submit element could trigger the 'submitted_and_valid' status. Greg I have written some forms with different names for the submit buttons. Then, however, the form doesn't return true for 'submitted_and_valid' for the second button. (i.e. the 'Finish' button in our example.) I haven't found a way to mark more than button as the submit button using the 'indicator' attribute. Am I incorrect in this? Thanks, Greg ___ 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
[html-formfu] Possible bug - Submit element when forms have errors
I think I might have found a bug. I have HTML::FormFu version 0.03007 installed. Here's what's happening. I created a form that ends with the following 3 submit buttons: --- - type: Submit name: submit value: Save for Later - type: Submit name: submit value: Finish - type: Submit name: submit value: Cancel These display as expected. However, if the form is submitted, contains errors, and then is re-displayed, the buttons all contain the same text. Here's the HTML that is generated: input name=submit type=submit value=Save for Later / input name=submit type=submit value=Save for Later / input name=submit type=submit value=Save for Later / All the values get set to the same value for some reason. Greg Coates ___ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu