HTML::FormFu::ExtJS::Element::Multi - Multi column


HTML-FormFu-ExtJS documentation Contained in the HTML-FormFu-ExtJS distribution.

Index


Code Index:

NAME

Top

HTML::FormFu::ExtJS::Element::Multi

VERSION

Top

version 0.090

DESCRIPTION

Top

This element creates a row of elements specified in elements. There are many ways to influence the layout of this element:

width

  - type: Multi
    label: Multi element
    attrs:
      width: 100

Specifies the width of each column

individualWidth

  - type: Multi
    label: Multi element
    attrs:
      individualWidth: [100, 200]
    elements:
      - type: Text
        label: 1st
      - type: Text
        label: 2nd

Sets the individual width of the items in pixels.

individualColumnWidth

  - type: Multi
    label: Multi element
    attrs:
      individualWidth: [.2, .3]
    elements:
      - type: Text
        label: 1st
      - type: Text
        label: 2nd

Specifies the relative width of the columns.

Each attribute specified in attrs gets passed to each column. This way you can change e.g. the label separator and label width:

  - type: Multi
    label: Appointment
    attrs:
      defaults:
        width: 50
      width: 150
      labelWidth: 35
      layoutConfig:
        labelSeparator:  .:.
    elements:
      - type: Text
        name: r11
        label: Date
      - type: Text
        name: r2
        label: Time
      - type: Checkbox
        label: st

NAME

Top

HTML::FormFu::ExtJS::Element::Multi - Multi column

SEE ALSO

Top

HTML::FormFu::Element::Multi

COPYRIGHT & LICENSE

Top

AUTHOR

Top

Moritz Onken <onken@netcubed.de>

COPYRIGHT AND LICENSE

Top


HTML-FormFu-ExtJS documentation Contained in the HTML-FormFu-ExtJS distribution.

#
# This file is part of HTML-FormFu-ExtJS
#
# This software is Copyright (c) 2011 by Moritz Onken.
#
# This is free software, licensed under:
#
#   The (three-clause) BSD License
#
package HTML::FormFu::ExtJS::Element::Multi;
BEGIN {
  $HTML::FormFu::ExtJS::Element::Multi::VERSION = '0.090';
}
use base "HTML::FormFu::ExtJS::Element::_Field";

use strict;
use warnings;
use utf8;


sub render {
	my $class = shift;
	my $self  = shift;
	
	my $super = $class->SUPER::render($self);
	my @elements;
	push( @elements, @{ $self->form->_render_items($self) } );
	unshift(@elements, { fieldLabel => $self->label, xtype => "textfield", hidden => \1})
	  if($self->label);
	my $data;
	my $width = $self->label ? 1 / @elements : 1 / (@elements);
	foreach my $i ( 0 .. @elements ) {
		my $empty_field = ($i == 0 && $self->label) ? 1 : 0;
		my %width = ();
		if($super->{individualWidth} && !$empty_field) {
			my $width = $super->{individualWidth}->[$i-($self->label?1:0)];
			%width =  (width => $width) if($width);
		} elsif($super->{individualColumnWidth} && !$empty_field) {
			my $width = $super->{individualColumnWidth}->[$i-($self->label?1:0)];
			%width =  (columnWidth => $width) if($width);
		}
		my $column =
		  { $empty_field ? () : %{$super}, 
		  	%width,
		  	layout => "form", items => [ $elements[$i] ] };
		push( @{$data}, $column );
	}
	pop( @{$data} );
	return { layout => "form", items => [ { layout => "column", items => $data } ] };
}
1;


__END__