On 03/14/10 12:43, Carl Franks wrote:
2010/3/13 Alex Povolotsky<tark...@over.ru>:
Hello!

I'm still missing some essential parts of DBIx interaction.

I have two simple tables

CREATE TABLE country (id serial primary key, name varchar(128) not null);
CREATE TABLE location (name varchar(128) primary key, country_id int not
null references country(id));
Hi,

Can you post the DBIx::Class schema definitions - in particular, the
relationship definitions?

Nothing classified )))

=== Location.pm ===
package Tourism::Schema::Result::Location;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
__PACKAGE__->table("location");
__PACKAGE__->add_columns(
  "id",
  {
    data_type => "integer",
    default_value => "nextval('location_id_seq'::regclass)",
    is_nullable => 0,
    size => 4,
  },
  "name",
  {
    data_type => "character varying",
    default_value => undef,
    is_nullable => 0,
    size => 128,
  },
  "country_id",
{ data_type => "integer", default_value => undef, is_nullable => 0, size => 4 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("location_pkey", ["id"]);
__PACKAGE__->has_many(
  "hotels",
  "Tourism::Schema::Result::Hotel",
  { "foreign.location" => "self.id" },
);
__PACKAGE__->belongs_to(
  "country_id",
  "Tourism::Schema::Result::Country",
  { id => "country_id" },
);


# Created by DBIx::Class::Schema::Loader v0.04006 @ 2010-03-14 11:40:59
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1E2rHbISqChwWkdBo3IpnA
1;
=== Location.pm ===

=== Country.pm ===
package Tourism::Schema::Result::Country;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
__PACKAGE__->table("country");
__PACKAGE__->add_columns(
  "id",
  {
    data_type => "integer",
    default_value => "nextval('country_id_seq'::regclass)",
    is_nullable => 0,
    size => 4,
  },
  "name",
  {
    data_type => "character varying",
    default_value => undef,
    is_nullable => 1,
    size => 128,
  },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("country_pkey", ["id"]);
__PACKAGE__->add_unique_constraint("country_name_key", ["name"]);
__PACKAGE__->has_many(
  "directions",
  "Tourism::Schema::Result::Direction",
  { "foreign.country" => "self.id" },
);
__PACKAGE__->has_many(
  "locations",
  "Tourism::Schema::Result::Location",
  { "foreign.country_id" => "self.id" },
);
__PACKAGE__->has_many(
  "tourists",
  "Tourism::Schema::Result::Tourist",
  { "foreign.citizenship" => "self.id" },
);


# Created by DBIx::Class::Schema::Loader v0.04006 @ 2010-03-14 11:40:59
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:leLBKTHMucr27LwnCnP0SA
=== Country.pm ===

=== location.yml ===
---
model_config:
  resultset: Location
elements:

  - type: Label
    label: Location

  - type: Text
    name: name
    label: Name
    constraints:
      - Required

  - type: ComboBox
    empty_first: 1
    empty_first_label: -select-
    label: Country
    name: country_id
    model_config:
       resultset: Country
       label_column: name
    constraints:
      - Required

  - type: Submit
    name: submit
=== location.yml ===

Seems to be rather primitive.

Alex.


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to