Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are select_field semantics backwards? #24

Open
robacarp opened this issue Feb 10, 2018 · 1 comment
Open

Are select_field semantics backwards? #24

robacarp opened this issue Feb 10, 2018 · 1 comment

Comments

@robacarp
Copy link
Member

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?

@faustinoaq
Copy link
Contributor

@amberframework/contributors Is this already solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants