Skip to content

Are select_field semantics backwards? #24

@robacarp

Description

@robacarp

I have a model with a type hash constant:

class Model < Granite::ORM::Base
  extend Query::BuilderMethods

  VALID_TYPES = {
    :one => 1,
    :two => 2
  }
end

Where the key of VALID_TYPES represents the human readable version of the mapping and the value represents what is stored in the database.

Using this in a form with select_field like this:

== form action: "/model/new", method: :post do
  == csrf_tag
  .form_group
    == select_field name: :type, collection: Model::VALID_TYPES

I get a somewhat unexpected result:

<select class="monitor_type" id="monitor_type" name="monitor_type">
  <option value="one">1</option>
  <option value="two">2</option>
</select>

Am I missing something obvious, or is this backwards?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions