[html-formfu] position element not found

Gabor HALASZ halasz.g at freemail.hu
Tue Jan 10 18:48:21 GMT 2012


On 1/10/2012 10:56 AM, Carl Franks wrote:
>
> Ah, it's the old FAQ :) - you need to call insert_after() on the
> parent of $position, not the $form object.
> So, do this:
>
>      $position->parent->insert_after( \%new_spec, $position );
>

Hi!

I tried this, but not works perfectly, the new element rendered two times:

<form action="" enctype="multipart/form-data" method="post">
<div class="requesttoken">
<input name="_token" type="hidden" value="athz4tb1vgpuzk40" />
</div>
<div class="fifty" id="fieldbox">
<label>
form.config.label.picture.manage.fieldset
</label>
<fieldset class="placeholder">
<div class="file label">
<label>Photo</label>
<input name="image" type="file" title="form.element.title.picture" />
</div>
<div class="image">
<input name="4" type="image" 
src="http://dhcp-125.ha.la.sz:3000/api/getproducticon/4" />
</div>
</fieldset>
</div>
<div class="image">
<input name="4" type="image" 
src="http://dhcp-125.ha.la.sz:3000/api/getproducticon/4" />
</div>
</form>

My code is now:

     if ( exists $c->flash->{productId} ) {
         $productId = $c->flash->{productId};
         $position = $c->stash->{form}->get_all_element({ type => 
'File', });

         $position->parent->insert_after( $c->stash->{form}->element( {
                 name => $productId,
                 src  => $c->uri_for( '/api/getproducticon/' . $productId ),
                 type => 'Image',
             } ), $position );

     }
     else {
         $c->model('Event')->error;
         $c->detach('/forbidden');
     }

Any idea?



More information about the HTML-FormFu mailing list