FAQ
Hi list,

I need some advice regarding repeatable elements. I've the following
database structure:

Table "clients": cli_id*, cli_name
Table "clients_tests": cli_id*, tst_id*, tst_result
Table "tests": tst_id*, tst_name

So, in my clients form, I'd like to have a "tst_result" for each test, like
this:

Client ID: [ input field for id ]
Client Name: [ input field for name]
Test A: [ input field for result ]
Test B: [ input field for result ]
Test C: [ input field for result ]

How can I do this configuration using repeatable fields?

Thanks in advance,


Jorge Augusto Senger
jasenger (at) gmail.com

use Perl;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20090826/3b07ad1d/attachment.htm

Search Discussions

  • Ascii King at Aug 26, 2009 at 7:25 pm

    Jorge Augusto Senger wrote:
    Hi list,

    I need some advice regarding repeatable elements. I've the following
    database structure:

    Table "clients": cli_id*, cli_name
    Table "clients_tests": cli_id*, tst_id*, tst_result
    Table "tests": tst_id*, tst_name

    So, in my clients form, I'd like to have a "tst_result" for each test,
    like this:

    Client ID: [ input field for id ]
    Client Name: [ input field for name]
    Test A: [ input field for result ]
    Test B: [ input field for result ]
    Test C: [ input field for result ]

    How can I do this configuration using repeatable fields?
    You need to set up your has_many relationship between your tables first.
    You would need to set up a has_many relationship in your Clients.pm.
    __PACKAGE__->has_many(client_tests =>
    'MyApp::Schema::Result::ClientTests', 'cli_id');

    Then, in your .yml configuration file:

    # THECOUNT --
    - type: Hidden
    name: tests_count

    # ** REPEAT CLIENT_TESTS --
    - type: Repeatable
    nested_name: client_tests
    counter_name: tests_count
    model_config:
    empty_rows: 1 <- Up this number to the number of tests you want
    new_rows_max: 100
    elements:

    # CLI_ID --
    - type: Hidden
    name: cli_id

    # TST_NAME --
    - type: Select
    name: tst_name
    model_config:
    resultset: Tests <- name of your tests table
    id_column: tst_id
    label_column: tst_name
    empty_first: 1

    # TST_RESULT --
    - type: Text
    name: tst_result

    Hope that helps. I'm a bit of a newb with this, so I hope it is accurate.
  • Ascii King at Aug 26, 2009 at 8:18 pm

    # TST_NAME --
    - type: Select
    name: tst_name
    model_config:
    Sorry, the name of the select element should be tst_id and not tst_name.
    # TST_NAME --
    - type: Select
    name: tst_id
    model_config:
  • Jorge Augusto Senger at Aug 26, 2009 at 9:27 pm
    Thanks Ascii King,

    Your example worked fine for me.


    Jorge Augusto Senger
    jasenger (at) gmail.com

    use Perl;

    On Wed, Aug 26, 2009 at 5:18 PM, Ascii King wrote:


    # TST_NAME --
    - type: Select
    name: tst_name
    model_config:
    Sorry, the name of the select element should be tst_id and not tst_name.
    # TST_NAME --
    - type: Select
    name: tst_id
    model_config:


    _______________________________________________
    HTML-FormFu mailing list
    HTML-FormFu@lists.scsys.co.uk
    http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20090826/4767c96c/attachment.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedAug 26, '09 at 6:28p
activeAug 26, '09 at 9:27p
posts4
users2
websitemetacpan.org...

People

Translate

site design / logo © 2022 Grokbase