Data-Type

 view release on metacpan or  search on metacpan

lib/Data/Type/Field.pm  view on Meta::CPAN

	my @html = $Data::Type::Field::XML->input( {

		id 		=> $this->id,
		class 	=> $this->type,

		type	=> $this->type,
		name	=> $this->name,
		size	=> $this->size,
		value	=> $this->default,
		maxlength=> $this->maxlength,

		ONFOCUS	=> $this->js_onfocus,

	});

return @html;
}

package Data::Type::Field::Form::Field::Popup;

Class::Maker::class { isa => [qw( Data::Type::Field::Form::Field )],

	public =>
	{
		string => [qw(default)],

		hash => [qw(labels)],

		array => [qw(values)],
	},
};

=head1

<select name="PLASTIK">
<option  value="eenie">Your first choice</option>
<option  value="meenie">meenie</option>
<option  value="minie">minie</option>
</select>

=cut

sub to_html : method
{
	my $this = shift;

	my @fields;

	foreach ( @{ $this->values } )
	{
		my $attribs = { value => $_ };
		
		$attribs->{selected} = 'true' if $this->default eq $_;
		
		push @fields, $Data::Type::Field::XML->option( $attribs , $this->labels->{$_} || $_ );
	}

	my @html = $Data::Type::Field::XML->select( {

		id 		=> $this->id,
		class 	=> 'popup',

		name		=> $this->name,

		}, @fields
	);

return @html;
}

package Data::Type::Field::Form::Field::Radio;

Class::Maker::class { isa => [qw( Data::Type::Field::Form::Field Data::Type::Field::Form::Input)],

	public =>
	{
		int => [qw( default )],

		string => [qw(value)],
	},

	default => 
	{
		type => 'radio',
		
		value => 1,
	},
};

=head1

<input type="radio" name="PLASTIK" value="ON" checked />

=cut

sub to_html : method
{
	my $this = shift;

	my $href_attr =
	{
		id 		=> $this->id,
		class 	=> $this->type,

		type	=> $this->type,
		name	=> $this->name,
		value	=> $this->value,
	};

	$href_attr->{checked} = 'checked' if $this->default;

	my @html = $Data::Type::Field::XML->input( $href_attr );

return @html;
}

package Data::Type::Field::Form::Field::Textarea;

Class::Maker::class { isa => [qw( Data::Type::Field::Form::Field Data::Type::Field::Form::Input)],

	public =>



( run in 1.876 second using v1.01-cache-2.11-cpan-364913b4093 )