Hi guys,
trying to create form elements that are not in the formconfig.yml I succeeded creating and rendering them to the page, but they don't arrive on submit. Any idea if something like that may be possible?

Form Config:
*******************************
---
indicator: submitindicator
elements:
  - type: Hidden
    name: submitindicator
    value: 1
    constraints:
      - Required

  - type: Submit
    name: submit
*******************************
The form gets submitted via jQuery so I need at least one hidden value as submit indicator.

In my Catalyst Controller I generate the additional checkbox elements that way:

*******************************
my $submit = $form->get_element({type => 'Submit'});
my $new_elem;
my @roles = $c->model('UMDB::Roles')->search({},{ order_by => 'role' },);
foreach ( @roles )
{
    $new_elem = $form->element({ type => 'Checkbox',
                                       name => ($_->id),
                                       label => $_->role,
                                       value => 1,
                                       });
$new_elem->add_attrs({checked => 'checked'}) if ($parent->roles- >find({id => $_->id }));
    $form->insert_before($new_elem, $submit);
}
*******************************

I know, these kind of dynamic elements are a potential security risk as soon as I don't know what element names get submitted, but in this example I know all my role id's and accept only param_values that I know of.

The problem is that I'm just receiving the element (e.g. submitindicator) found in the Form Config, all the Controller-added elements don't make it to the $form->submitted_and_valid part...

Thanx in advance for reading this till here, and for any ideas,

Johannes


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

Reply via email to