[html-formfu] position element not found
Carl Franks
fireartist at gmail.com
Tue Jan 10 09:56:11 GMT 2012
On 10 January 2012 09:16, Gabor HALASZ <halasz.g at freemail.hu> wrote:
> On 1/10/2012 9:38 AM, Carl Franks wrote:
>>
>> Hi,
>> Can you provide the config / code which sets-up the form, and the rest
>> of your code which looks like it's cut off mid-line?
>
>
> Hi!
>
> My configs:
>
> picture/manage.conf:
>
> <<include ../common/filter.conf>>
> <elements>
> type Block
> <attributes>
> id fieldbox
> class fifty
> </attributes>
> <elements>
> type Block
> tag label
> content_loc form.config.label.picture.manage.fieldset
> </elements>
> <elements>
> type Fieldset
> <attributes>
> class placeholder
> </attributes>
>
> <elements>
> <<include ../common/element/file.picture.conf>>
> </elements>
>
> </elements>
> </elements>
>
> The included elements:
>
> common/filter.conf:
>
> filter TrimEdges
> filter HTMLEscape
> filter HTMLScrubber
>
> common/element/file.picture.conf:
>
> type File
> name image
> label_loc form.element.label.picture
> <attributes>
> title form.element.title.picture
> </attributes>
> <constraints>
> type File::MIME
> types image/bmp
> types image/gif
> types image/jpeg
> types image/png
> types image/tiff
> </constraints>
> <constraints>
> type File::MinSize
> min 32768
> </constraints>
> <constraints>
> type File::MaxSize
> max 524288
> </constraints>
>
> My Ctalyst controller:
>
> =head2 manage
>
> Picture manager logic
>
> =cut
>
> sub manage : Chained( 'base' ) : PathPart( 'manage' ) : Args( 0 ) : Form {
> my ( $self, $c ) = @_;
>
> $c->stash->{title} = 'template.title.picture.manage';
>
> $c->stash->{form}->load_config_file('picture/manage.conf');
>
>
> if ( exists $c->flash->{productId} ) {
>
> my $position = $c->stash->{form}->get_all_element({ type => 'File',
> });
> # my $position = $c->stash->{form}->get_all_element;
>
> use Data::Dumper;
> $c->log->debug( 'HIER: ' . $position );
>
> $c->stash->{form}->insert_after( $c->stash->{form}->element( {
> name => '5',
> src => $c->uri_for( '/api/getproducticon/' .
> $c->flash->{productId} ),
> type => 'Image',
> } ), $position );
>
> }
> else {
> $c->model('Event')->error;
> $c->detach('/forbidden');
> }
>
> $c->stash->{form}->process;
>
>
> return;
> }
>
> Thanks
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 );
More information about the HTML-FormFu
mailing list