FAQ
hi,

the constraint in the repeatable block won't be triggerd, for the "normal" select below, it works. any hints how to modify the config so the repeatable part works too?

thanks
josef

elements:
- type: Hidden
name: count

- type: Repeatable
nested_name: user_depots
counter_name: count
elements:
- type: Hidden
name: id

- type: Select
name: company
label: Company
empty_first: 1
empty_first_label: 'choose'
model_config:
model: Comp
resultset: Companies
id_column: id
label_column: long_name
constraints:
- Required

- type: Select
label: 'Test'
name: comp
empty_first: 1
empty_first_label: 'choose'
model_config:
model: Comp
resultset: Companies
id_column: id
label_column: long_name
constraints:
- Required

Search Discussions

  • Carl Franks at Dec 19, 2009 at 8:46 am
    Hi Josef,

    Which version of HTML-FormFu are you using?
    There was a fix in v0.04000 for constraints in a Repeatable with nested_name.

    This is tested for in:
    t/repeatable/constraints/required.t
    t/repeatable/constraints/required.yml

    (Assuming you're using Catalyst) could you send a dump of
    $c->request->params() and the $form object after process() has run?

    Carl
  • Josef Chladek at Dec 19, 2009 at 9:50 am

    Am 19.12.2009 um 09:46 schrieb Carl Franks:

    Hi Josef,

    Which version of HTML-FormFu are you using?
    There was a fix in v0.04000 for constraints in a Repeatable with nested_name.

    This is tested for in:
    t/repeatable/constraints/required.t
    t/repeatable/constraints/required.yml

    (Assuming you're using Catalyst) could you send a dump of
    $c->request->params() and the $form object after process() has run?
    hi carl,

    my version of formfu is 0.05001 and FormFu::Model::DBIC 0.05002

    params

    $VAR1 = {
    'count' => '5',
    'submitted' => 'Submit',
    'user_depots_1.company' => '', <== should raise error, does not
    'user_depots_1.id' => '1',
    'user_depots_2.company' => '20',
    'user_depots_2.id' => '2',
    'user_depots_3.company' => '1097',
    'user_depots_3.id' => '3',
    'user_depots_4.company' => '4',
    'user_depots_4.id' => '4',
    'user_depots_5.company' => '49',
    'user_depots_5.id' => '5'
    };

    Dump of $form much to big, because a lot of dbic models involved, what part would be interesting here?

    when I follow the changes described here:
    http://lists.scsys.co.uk/pipermail/html-formfu/2009-January/001665.html

    I get it working.

    thanks
    josef
  • Carl Franks at Dec 19, 2009 at 11:13 am
    2009/12/19 Josef Chladek <josef.chladek@gmail.com>:
    when I follow the changes described here:
    http://lists.scsys.co.uk/pipermail/html-formfu/2009-January/001665.html

    I get it working.
    That's refering to $block->repeat() being called, which only happens during
    $form->model->default_values()
    ... so the question is why are you needing to call that *after* a form
    submission?

    Generally, the logic should be:

    if ( $form->submitted_and_valid ) {
    $form->model->update;
    }
    elsif ( ! $form->submitted ) {
    $form->default_values;
    }

    What does your controller look like?

    Carl
  • Josef Chladek at Dec 19, 2009 at 11:37 am

    Am 19.12.2009 um 12:13 schrieb Carl Franks:

    2009/12/19 Josef Chladek <josef.chladek@gmail.com>:
    when I follow the changes described here:
    http://lists.scsys.co.uk/pipermail/html-formfu/2009-January/001665.html

    I get it working.
    That's refering to $block->repeat() being called, which only happens during
    $form->model->default_values()
    ... so the question is why are you needing to call that *after* a form
    submission?

    Generally, the logic should be:

    if ( $form->submitted_and_valid ) {
    $form->model->update;
    }
    elsif ( ! $form->submitted ) {
    $form->default_values;
    }

    What does your controller look like?
    carl, thank

    found the problem, I always called

    $form->model->default_values

    regardless if submitted or not, putting that in the not submitted part of the else made it work - thanks!

    btw, I have 5 of those selects in the form, which need all to be present (which works now) AND should be unique. I can achieve this by making a unique constraint in the db and catch the error in an eval around $form->model->update. my problem: how can I force_error on the correct field? I can't seem to get the fields within the repeatable block. I normally do this like that:

    $form->get_constraint('email')->force_errors(1);
    $form->process;
    $form->form_error_message('not saved');
    $form->force_error_message(1);

    how would I select the correct constraint (get_constraint) within the repeatable block? or is there an easier way to have unique select values within the repeatable block without evaling the db call?

    thanks
    josef
  • Josef Chladek at Dec 19, 2009 at 1:55 pm

    Am 19.12.2009 um 12:37 schrieb Josef Chladek:

    btw, I have 5 of those selects in the form, which need all to be present (which works now) AND should be unique. I can achieve this by making a unique constraint in the db and catch the error in an eval around $form->model->update. my problem: how can I force_error on the correct field? I can't seem to get the fields within the repeatable block. I normally do this like that:

    $form->get_constraint('email')->force_errors(1);
    $form->process;
    $form->form_error_message('not saved');
    $form->force_error_message(1);

    how would I select the correct constraint (get_constraint) within the repeatable block? or is there an easier way to have unique select values within the repeatable block without evaling the db call?
    found a way to make this work:

    addedd

    validator: 'Cat::UniqueCopmanyInDepots'

    in my config, made

    Cat/lib/HTML/FormFu/Validator/Cat/UniqueCopmanyInDepots.pm

    as described in http://search.cpan.org/~cfranks/HTML-FormFu-0.06000/lib/HTML/FormFu/Validator.pm

    very nice solution - thanks for that carl!

    josef

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedDec 18, '09 at 2:51p
activeDec 19, '09 at 1:55p
posts6
users2
websitemetacpan.org...

2 users in discussion

Josef Chladek: 4 posts Carl Franks: 2 posts

People

Translate

site design / logo © 2022 Grokbase