On Tuesday, April 29, 2014 6:42:03 PM UTC-7, Snarke wrote:
>
> It’s not *exactly* Sequel, but it’s Jeremy, and it’s for use *with* Sequel 
> (at least for me). 
>
> Jeremy, could you share the *complete* source code for the Forme demos? As 
> is, I’m afraid they don’t make any sense to me. I’m trying to get a 
> drop-down menu, as seen from the “Default” demo for “Artist.” The template 
> code says 
>
>          form_opts[:one]||{} 
>

The Forme demo site is part of the forme 
repository: https://github.com/jeremyevans/forme/tree/master/demo-site
 
You are right that the form options/template code sections are overly terse 
for most of the basic examples.  That's due to the fact that the basic 
examples all use the same template code, and the only difference is the 
options used.  This is a double edged sword, showing how flexible Forme is, 
but being very hard to learn from. It really should focus more on teaching 
people how to use Forme.

Er, wha? Looking at “Association Radios/Checkboxes” I’m guessing that 
> form_opts is somehow 
>
>         form_opts = {:wrapper=>:li, :inputs_wrapper=>:ol, 
> :many=>{:as=>:checkbox}, :one=>{:as=>:radio}} 
>
> which would, for *that* form, mean that 
>
>                  form_opts[:one]||{} 
> becomes 
>                 {:as=>:radio} 
> except that 
>         f.input{my_own_field, {:as=>:radio}} 
> didn’t work. I still haven’t figured out where in the rdoc docs I even 
> find what goes after “:as”, or what other options go there. 


The :as options are documented briefly in the README.  They are also 
documented in the method RDoc, but for private methods, so they don't show 
up in the documentation unless you use rdoc -V private.  However, even that 
probably doesn't show all of the available options.   In general, Forme is 
lacking in documentation, so looking at the specs is probably the best way 
to see what is supported.  
 

> “my_own_field” is, btw, a PostgreSQL enumerated custom type. It’s just 
> dying to be a drop-down selector again.


As explained in the README, :as=>:radio only works for many_to_one 
associations.  For a custom enumerated type, you can use :type=>:radio, but 
that produces a single radio input.  For multiple radio inputs, you need to 
loop over the options and create a radio input for each option.  If you 
want a select box with multiple options, you can do that with a single call:

  f.input(:field, :type=>:select, :options=>%w'value1 value2 value3')

If you have more questions, please let me know.  I know Forme could benefit 
from better documentation and general polish, but as it still isn't very 
popular, I don't devote much time to it.  I realize this is a chicken and 
egg scenario.  I would love additional help with Forme, so if it's 
something that interests you, please do send pull requests or get in touch 
with me via email or IRC to discuss your ideas.  Replying here is fine as 
well.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.
  • Forme? Dave Howell
    • Re: Forme? Jeremy Evans

Reply via email to