Grid #42
Replies: 21 comments
-
Google Group Date: Sun, 11 May 2014 17:11:47 -0700 On Sunday, May 11, 2014 4:25:39 PM UTC-7, Dave Howell wrote:
I see at Note that most times you add a commit that changes behavior, you are going rspec spec/forme_spec.rb if you just want to run the core forme specs without the For simple things where you know the API you want to use an advance, it can
This is because if you don't provide the :inputs option to subform, it
|
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 11 May 2014 19:01:15 -0700 On May 11, 2014, at 17:11 , Jeremy Evans jeremy...@gmail.com wrote:
I do? Er, why?
{looks in specs directory} {blinks} Boy, that’s rather like reading PERL code. It almost makes sense. Y’know, I don’t really expect anybody to ever use my fork, including me. I think of it more as a fairly tidy way to propose changes for you to review. You might, on occasion, actually say to yourself “oh, that seems fine.” You’re more likely to say “well, I see what Dave’s getting at here, but that’s fairly inflexible/will fail under these other conditions/isn’t idiomatic with the rest of the code” and then rewrite it properly. Sometimes you’ll say “oh, he’s trying to do X, but the existing code already does that in this way he didn’t figure out,” and sometimes you’ll say “Well, that’s just a dumb idea.” At some point I will throw the whole thing away, and fork a fresh new copy from yours. That’s my plan, at least. |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 11 May 2014 22:11:39 -0700 On May 11, 2014, at 17:11 , Jeremy Evans jeremy...@gmail.com wrote:
I think that being able to contain a subform inside a tag should be independent of whether or not I use the :inputs parameter. . . .
I’m thinking at this point that Forme actually is doing two very different things. First (esp. with the Sequel bridge), it is building input statements that can present multiple instances of associated models of a model and be able to keep separate, and identify, which data belong to which record when the form is submitted. At the same time, Forme is providing markup utilities, making it easier to affect the appearance of the form. When I say Form.form(sequelobject, form_attr, form_opts), the first argument is for the first function, the second argument is for the second, and the third tends to affect both of them. More specifically, ::form is going to eventually be a tag, and the 2nd argument to it will become the tag’s attributes, yes?::input also is going to create a tag, possibly with children. But to add an attribute to this one, I have to do :attr=>{:my attribute => “something”} I would propose to you that, rather than have .inputs always call Form#_inputs, a better solution is to not have an :inputs_wrapper at all. Let’s start with the form-functional tags: et cetera. Most if not all of these may have not only functional attributes, but also appearance ones. Frequently, we want to contain them within other tags (e.g. , ), and will want to set attributes on same; the wrapper. Finally, in order to avoid having to specify wrappers for every single form tag, it’s nice to be able to provide a default wrapper for a tag’s children. Now, if I understand what’s going on in Forme at the moment, when I specify a :wrapper for an .input, I’m specifying an external, or shell wrapper. But when I specify the :wrapper on a .form, I’m specifying an internal, or inherited wrapper. .inputs is both a way of iterating over a list of objects to generate tags for, but also an intermediate stage that can provide grouping for tags. It’s wrapper is specified by .form; ergo :inputs_wrapper is also an inherited wrapper. .subform strongly implies grouping as well, although I’m not sure if it’s unavoidable. Would one automatically group a subform that had only one record? Probably. Anyway, I would like to offer for your consideration the following re-design. Forme.form, .input, .inputs, .tag, .subform, and possibly a few more should all accept :wrapper as an optional parameter, and all of them would use the wrapper as a shell: it controls what surrounds the tag they represent. It also defaults to being the wrapper inherited by this elements children. Then there’s another parameter (replacing :inputs_wrapper, I guess), that could be set to an alternative inherited wrapper. Thus, if you want this element to be in a list, but for the childrent to be assembled into a table, you don’t have to tell every single child :wrapper=> table; you can set it once in the parent and let them all inherit it. Some wrapping structures don’t permit input elements at every level. You put a with an input and another
, no big deal, but if you start a list, you then have to move into a list item before you can do input, and a table requires two steps.
Forme.form(obj, :wrapper=>:div) would put a around the form. Forme.form(obj, :wrapper=>:olist) would put the form inside an
Forme.form(obj, :wrapper=>:div){|f| f.input(:album)} would make the input a child of another . With Forme.form(obj, :wrapper=>:olist){|f| f.input(:album)}, the :list wrapper knows that the input has to be inside an
|
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 12 May 2014 08:40:11 -0700 On Sunday, May 11, 2014 10:11:39 PM UTC-7, Dave Howell wrote:
I think that means that subform should always call Form#_inputs (using the
I tend to think of it as a Forme is doing a single thing (building an html
Correct. In some cases to make simple things easy you can use an option
The :inputs_wrapper is basically the equivalent of :wrapper, except that it
Basically, you want to continue to use inputs_wrapper and wrapper as I think such a thing is possible with some refactoring. I think it makes Some wrapping structures don’t permit input elements at every level. You
This actually doesn't happen. If you want to wrap the form in a tag, you
|
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Tue, 13 May 2014 22:39:17 -0700 On May 12, 2014, at 8:40 , Jeremy Evans jeremy...@gmail.com wrote:
I know. But it seems inconsistent to me, so I’m suggesting it should. Or, “:wrapper” should not be a parameter that .form accepts, if it doesn’t actually wrap the form, since it does affect what gets wrapped around the other things that accept it. In a nutshell, I think :wrapper ought to mean the same thing whenever it gets used. It could either set what is used to wrap the command it’s passed to, or it could set what the children get wrapped in. The problem with having it set up the the children is that it becomes a hassle to then override the wrapper for a particular input, because you’d have to do the override in a parent, but a parent of just this one input. If, on the other hand, :wrapper defines what gets wrapped around the command, then you can just set it for a particular input and it changes what that input is wrapped in. But, that means if you set :wrapper on .form, the form should be wrapped.
Are you saying you think we cannot, or that we should not? Also, that’s not exactly what I’m proposing. When Forme needs to spit out an tag, whether or not .inputs would need to be called depends on what wrapper is active. If it’s the :div wrapper, the answer is “no.” If it’s the :olist wrapper and we’re not currently inside an
This also means if I’ve said Forme.form(obj, :children_wrapper=>:table) do |f|… or if saying just :wrapper=> does not put the form inside a table, then if my next line is f.input(:sometextfield), the wrapper would respond with “I’m not already in a table? I need to be, and then inside a row, and then I can make a cell, and then I have to close it all so when I’m all done spitting tags we’re back where we started.” Conversely, if I say
each input, during wrapping, has to call .inputs in order to get wrapped in a tag, before it can then put its label in one and its in a following one, and then pop back out with the .subform has an implicit .inputs, or at least it does if it’s an XXX_to_many relationship.
The first .subform above would wrap each record in a . Each field of the record would then have to wrap itself in a before it could then wrap itself in a , leaving each input to just wrap itself in a
|
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Wed, 14 May 2014 08:59:45 -0700 On Tuesday, May 13, 2014 10:39:17 PM UTC-7, Dave Howell wrote:
Well, it doesn't seem inconsistent to me, but maybe that's because I wrote Forme::Form - Sets the default values for Inputs created by the Form Also, :wrapper (and most other transformers) only handle Inputs, and the created by Forme::Form#form isn't an Input, it's a Tag. So I don't think it's possible for :wrapper to wrap the tag even if we exposed an option for it.
This only makes sense if the options could mean the same thing for both
As I mentioned the tag created is a Tag, not an Input, and wrappers
Should not. It possible to do so by making Forme.form automatically call
|
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Wed, 14 May 2014 12:19:33 -0700 On May 14, 2014, at 8:59 , Jeremy Evans jeremy...@gmail.com wrote:
Aha. You’re thinking about the intermediate object, and I’m looking at the end result. .input might make an Input, but Input makes a Tag, and Tag makes a tag. is a tag. is a tag. is a tag.
If they can’t mean the same thing, then they shouldn’t be the same parameter.
If wrappers only operate on Inputs, then I submit that only Inputs should have a :wrapper parameter.
I know. I don’t propose it lightly.
Actually, I don’t want it for reducing the amount of code I write. I want it because I think it will make writing the code easier. I’ve been struggling to use Forme because, as you may have noticed, I keep tripping over what it does vs. what I expect. I think we’ve just exposed one of the paradigms that had escaped me until now: that you see Forme methods that make “Inputs” as fundamentally different from ones that create “Tags.” As far as I was concerned, they all create tags, so where you saw blue commands and yellow commands, I just saw green commands, and a parameter that did X with blue commands did not-X with the yellow ones, leaving me baffled.
Well, you’d said a few weeks back that one of the reasons Forme wasn’t esp. well documented was because people weren’t using it a lot. It’s a bit of a chicken-and-egg scenario, but I know I would find it much easier to explain my version than yours. Of course, that’s not really that surprising. :) Given that it’s currently rev. 0.9.2, I thought that there might be an opportunity with a 1.x bump to, in fact, do an incompatible release, should the change be worth it. I’ll table this for now, but I gotta say, even if the functionality of Forme doesn’t change, it’s still going to need an incompatible release in order to make what it does do more obvious and clear. I’m sure I’ll eventually figure out why you named two of the methods “.input” and “.inputs”, but for me, these two almost-identically named methods do wildly different things, and the similarity in naming is still incomprehensible. :wrapper appears to be short for “:input_wrapper,” and to also have “:inputs_wrapper”, well, I long ago installed a .gsub(‘inputs’,’something other than what “inputs” means to me’) in my head for Forme. |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Wed, 14 May 2014 13:46:37 -0700 On Wednesday, May 14, 2014 12:19:33 PM UTC-7, Dave Howell wrote:
Well, the end result may be a tag, but most of the transformers require an
I disagree that just because two options have the same name, they should This begs the question, if you don't want the options to have the same
Well, that's an important difference in understanding. Input and Tag
Certainly breaking backwards compatibility is possible, and there are
input represents a singular input, inputs represents a group of related The reason for the naming of :wrapper and :inputs_wrapper is that :wrapper Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Wed, 14 May 2014 16:13:24 -0700 On May 14, 2014, at 13:46 , Jeremy Evans jeremy...@gmail.com wrote:
Which I believe reflects the fact that is an HTML tag that cannot have children, wheras many other HTML tags can?
No, a Form is not an Input, but then, I don’t usually work with Input, I’m usually calling .input on the Form instance. I’m never handling the Input object; I pass things to to the .input method, and I get a out the other side when the form closes.
Can I get back to you on that? I think I need to understand .form better before I can give you a confident reply.
Given how remarkably clear the Sequel library is, or rather, how good a job it does at failing to be as opaque as it obviously could be, especially given the astonishing flexibility and complexity it encapsulates, I took for granted that you weren’t doing anything with Forme that you thought was confusing or incomprehensible. I also am quite clear that I am not the core audience for Forme. When I compare what I have created/coded/programmed, I think the evidence is fairly strong that I’m a pretty damn good programmer. However, because it’s not my full-time gig, my knowledge is very lumpy: I know a lot about X, and almost nothing about Y. Also, a lot of my knowledge has cobwebs. There’s also the lack of formal training, especially in modern programming practices or even terminology. On the third hand, one of the other skills I have is being other people. When I was doing game design/testing/editing at Wizards of the Coast, one of the things I specialized in was pointing out what might be confusing to non-core-gamers. Would kids get this? Would my Mom? So I’m trying to be as clear as I can about what has been giving me trouble with Forme, and why, and how I think it could me made clearer, particularly for people who are fairly new to programming or Ruby or HTML forms or whatnot. If I do that well, you can in turn say “Ah, yea, I can see how that might also confuse some of my core audience,” or “pfft, 99.9% of the people who’d even look at Forme know exactly what a DSL is, there’s no need to spell it out.” One of the things I really love about Ruby is its guessability. Whether its [4..76], a Sequel::Model, or a hash, ::each does the same thing, or something so similar as to be quite obvious. That’s awesome.
The shorter name is nice. Okay, I’ll keep working on figuring out what Forme really does, and get back to you regarding possible aliases for parameters. |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Wed, 14 May 2014 20:22:54 -0700 On Wednesday, May 14, 2014 4:13:24 PM UTC-7, Dave Howell wrote:
That's true, but no really related. tags can have children, but in Forme input(:select) and tag(:select) operate differently. You can do: input = f.input(:select, :options=>[1, 2, 3]) but: tag = f.tag(:select) tag << f.tag(:option, {}, 1) tag << f.tag(:option, {}, 2) tag << f.tag(:option, {}, 3) The f.input(:select) call is self contained, but the f.tag call is not. You can always add children to an existing Tag instance. input represents a singular input, inputs represents a group of related inputs. The method names input and inputs I took from the very popular Formtastic library (https://github.com/justinfrench/formtastic). I don't think they are confusing or incomprehensible, though I suppose we could could add an input_group alias for inputs if that would make things clearer. Given how remarkably clear the Sequel library is, or rather, how good a job it does at failing to be as opaque as it obviously could be, especially given the astonishing flexibility and complexity it encapsulates, I took for granted that you weren’t doing anything with Forme that you thought was confusing or incomprehensible. I also am quite clear that I am not the core audience for Forme. When I compare what I have created/coded/programmed, I think the evidence is fairly strong that I’m a pretty damn good programmer. However, because it’s not my full-time gig, my knowledge is very lumpy: I know a lot about X, and almost nothing about Y. Also, a lot of my knowledge has cobwebs. There’s also the lack of formal training, especially in modern programming practices or even terminology. On the third hand, one of the other skills I have is being other people. When I was doing game design/testing/editing at Wizards of the Coast, one of the things I specialized in was pointing out what might be confusing to non-core-gamers. Would kids get this? Would my Mom? So I’m trying to be as clear as I can about what has been giving me trouble with Forme, and why, and how I think it could me made clearer, particularly for people who are fairly new to programming or Ruby or HTML forms or whatnot. If I do that well, you can in turn say “Ah, yea, I can see how that might also confuse some of my core audience,” or “pfft, 99.9% of the people who’d even look at Forme know exactly what a DSL is, there’s no need to spell it out.” And I appreciate that very much. In some cases, what Forme does may not be intuitive, and may not be able to made intuitive, in which case the hope is that the documentation is good enough to explain how things work. Obviously we aren't there yet. One of the things I really love about Ruby is its guessability. Whether its [4..76], a Sequel::Model, or a hash, ::each does the same thing, or something so similar as to be quite obvious. That’s awesome. That's certainly the type of API I try to create. But it isn't always possible to do so, or if it is possible, sometimes I fail to do so. Thanks, Jeremy |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Thu, 15 May 2014 09:13:12 -0700 On Sunday, May 11, 2014 4:25:39 PM UTC-7, Dave Howell wrote:
I've added a :grid option to subform that does basically what you want. Let me know what you think. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 18 May 2014 01:50:24 -0700 On May 15, 2014, at 9:13 , Jeremy Evans jeremy...@gmail.com wrote:
Yes, that does indeed look like what I want.
{tinker tinker} So I take it this is all still development-grade code? I think I’m either going to have to try to get an actual web server running on my laptop, or push my local github-ish copy of forme onto my web server. Hmm. |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 18 May 2014 03:08:03 -0700 I pushed it onto the web server. I’m loading it with an explicit path. This mostly worked:
The subform is ignoring my “Don’t label this please” label of “”. I did successfully tack the ‘delete’ text at the end of the row. It’ll become a link next. Oh. Hmm. Well, partially successfully. There’s an extra empty cell between my ‘delete’ and the last cell of the subform. Integers are getting ginormous text input boxes, and :name needs to be a heck of a lot wider. To be sure, my previous solution wasn’t the most elegant one. Your form comes back as a Forme:Tag. Mine came back as a REXML:Element. If I convert my Forme form into REXML, I can do the same patch:
My hunch is that a better way to do this with Forme is to drop the inputs out of the parameters and into the block, where I can add attributes without making it turn into one ungodly long line. Yes? Is there a way to set a default for database integer fields so that the end result is something like <input name=“field name” value=“4325” size=“8”> ? |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 18 May 2014 08:11:32 -0700 On Sunday, May 18, 2014 1:50:24 AM UTC-7, Dave Howell wrote:
I'm not sure what you mean by "development-grade" code. There hasn't been In the meantime, you can either push your local repo to your webserver, or Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 18 May 2014 08:34:01 -0700 On Sunday, May 18, 2014 3:08:03 AM UTC-7, Dave Howell wrote:
The :label option is not respected for subform, you need to use :labels.
If you are trying to add delete: f << f.tag(:td, {}, ['delete'])
For sizing, you can either use css for styling or input_defaults with f.subform(:items, :inputs=>[:quantity, [:name, {:size=>100}], :price,
That may look better.
As shown above, :input_defaults=>{:number=>{:size=>8}} should get what you Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 13:32:24 -0700 On May 18, 2014, at 8:11 , Jeremy Evans jeremy...@gmail.com wrote:
That’s what I mean. I can’t get the new features merely by upgrading the gem. :) |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 14:41:04 -0700 On May 18, 2014, at 8:34 , Jeremy Evans jeremy...@gmail.com wrote:
Where do I put :input_defaults? I’ve tried the first and second hashes of .form, the opt hash of .inputs, the opt hash of .subform, and as a parameter for .inputs, .subform, and .input. None of them had an effect. |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 17:27:01 -0700 On Monday, May 19, 2014 2:41:04 PM UTC-7, Dave Howell wrote:
It's a Form option, so the second hash to .form (the first hash is the Forme.form({}, :input_defaults=>{:number=>{:size=>8}}){|f| puts Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 20:11:21 -0700 On May 19, 2014, at 17:27 , Jeremy Evans jeremy...@gmail.com wrote:
Aha. It’s not working because that input’s type is “text” not “number.” In Postgres, it’s a Numeric data type, not an integer. But I would have expected that to still be a number . . . . |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 21:59:21 -0700 On Monday, May 19, 2014 8:11:21 PM UTC-7, Dave Howell wrote:
I'm not sure how well the number input type is supported for non-integer Note that you can use :type=>:number to force the :number type for a Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Mon, 19 May 2014 22:21:50 -0700 On May 19, 2014, at 21:59 , Jeremy Evans jeremy...@gmail.com wrote:
Hmm. But if I’m putting a special parameter in the input, I might as well just make that parameter :size=>8. A stepper for a dollar amount really doesn’t make sense anyway. |
Beta Was this translation helpful? Give feedback.
-
Google Group Post: https://groups.google.com/g/ruby-forme/c/_rDVitPcgmk
Google Group Date: Sun, 11 May 2014 16:25:39 -0700
Google Group Sender: group...@grandfenwick.net
BTW, I’m really quite amazed at how patient you are. THIS post is hopefully rant-free. Just questions and suggestions.
Okay, I’ve pushed the :tr inputs wrapper and :td wrapper back to GitHub.
And here’s this form, where the top part is a two-column list, easily created with :inputs_wrapper => :table and :wrapper => :trtd
Below that, but part of the same form, is the invoice item list, which I’d like to lay out in a grid. Now I’m kinda stuck.
What I think ought to work is
Except that .subform doesn’t take any options except :legend and :inputs. I can get the individual subform items into cells by specifying :wrapper=>:td for each of them, but I still can’t get the parent in place.
Even slicker would be if I could do
.inputs itself would wrap its children in the
tag, the subform would put each associated item in the , each input gets a . I forget off the top of my head.It isn’t hard for me to imagine wanting to do something like
I’m not sure I’ve put the various wrappers in the correct spots, but I think you get the idea.
Now, my current form builds a table that, at the top, is pretty much exactly what :inputs_wrapper=>:table, :wrapper=>:trtd, :labeler=>:explicit creates. Except for one little glitch. My labels are bold and flush right. This is handled by the CSS, which does things to td:first_child for tables that are “list” class.
Which is to say:
et cetera et cetera.
I can add attributes to the
tag with :wrappers_attr, but there doesn’t appear to be an equivalent :input_wrappers_attr parameter. How do I set the “class” attribute on my table? (Yes, in this particular case, I could also redefine the CSS and set “class=‘list’” on each row, but I don’t know that that would always work, and it’s also messier….)Beta Was this translation helpful? Give feedback.
All reactions