[html-formfu] position element not found error when using insert_before

mohanprasad mohan at thebizmo.com
Thu Oct 15 07:12:12 GMT 2009


Hi,

I am trying to insert a new element in my catalyst controller action using
below code.
i have two hidden fileds, one text box, i am trying to insert the new
element before hidden fields.

my $form = $self->form;
my $file = "restricted/add/product";
$form->load_config_filestem($file);
$form->process;
$c->stash->{form} = $form;
my $new_element = $form->element( { type => 'Block', tag => 'label', content
=> 'file upload error' } );
my $pos = $form->get_element({ type => 'Hidden', name => 'media_id'});
my $hidden_fields = $form->hidden_fields;
$c->log->debug("hidden fields = $hidden_fields");
$form->insert_before($new_element, $pos);

the yml form for the same is below.

---
elements:
  - type: Fieldset
    elements:
      - type: Hidden
        name: media_id
      - type: Hidden
        name: cover_id
      - type: Text
        name: name
        label_loc: 'Title*:'
        attributes:
            title_loc: Enter Title here
        add_attributes:
          class: text
        constraints:
          - type: Required
            message_loc: 'This field is required'
          - type: Regex
            not: 1
            regex: '^\s+$'
            message_loc: "Please proivde valid title"

but i am getting follwing error while doing that.

[debug] Hidden Fiedls = <input name="media_id" type="hidden" value=""
id="add_track_media_id" /><input name="cover_id" type="hidden" value=""
id="add_track_cover_id" />
[error] Caught exception in Bizmo::Controller::Restricted::Add->data
"position element not found at
/home/mohan/biz/trunk/script/../lib/Bizmo/Controller/Restricted/Add.pm line
247"

line 247 is : $form->insert_before($new_element, $pos);

Could anyone please let me know where i am doing wrong?

Best Regards,
Mohan
-- 
View this message in context: http://n2.nabble.com/position-element-not-found-error-when-using-insert-before-tp3827638p3827638.html
Sent from the HTML-FormFu mailing list archive at Nabble.com.



More information about the HTML-FormFu mailing list