Forme.new? #51
Replies: 2 comments
-
Google Group Date: Sat, 31 May 2014 23:19:34 -0700 On Saturday, May 31, 2014 4:18:29 PM UTC-7, Dave Howell wrote:
Actually, calling #input or #tag on a Forme::Form instance will save a
You can do most or all of this already, I think, but what you need to do is a) You can pass this Forme::Tag instance as a parameter, even if it isn't frm = Forme.form(...) do |f|
Assuming you added an appropriate manifest method, something similar would
I'm not sure how well this would work with yaml, but at least with marshal If you want to use a single form in multiple places with different objects,
I can see a use case for being able to reopen a form tag (any tag really), Thanks, |
Beta Was this translation helpful? Give feedback.
-
Google Group Date: Sun, 1 Jun 2014 01:38:16 -0700 On May 31, 2014, at 23:19 , Jeremy Evans [email protected] wrote:
Aha! There is an essential bit of insight that might have taken me ages to figure out on my own.
I just grabbed yaml as a convenient synonym for serialization. (I think that’s the word I mean…) |
Beta Was this translation helpful? Give feedback.
-
Google Group Post: https://groups.google.com/g/ruby-forme/c/p1QNWkECQqw
Google Group Date: Sat, 31 May 2014 16:18:25 -0700
Google Group Sender: [email protected]
So, if I understand what I’m seeing in the documentation, Forme doesn’t instantiate in any sort of permanent way? That is, there is no Forme.new. There’s a Forme::Form.new, but if I call .input or .tag on an instantiated Forme form, it throws a a Forme::Tag right back at me without retaining any memory of that object. The methods that actually affect instance variables are things like formatters and serializers and the like.
Currently, I’m building most of the actual web pages on my internal site by starting with thispage=WebPage.new, and then adding things to the various parts of the page as I go along. The last thing I do before returning is thispage.compose, which spits out the entire HTML structure for delivery by Ramaze/Innate/Rack/Thin whatnot.
The following observations are not a request to change Forme; they are me doing some hypothesizing to understand Forme better. Basically, I’m going to try some “If Forme were like this, then I could do such-and-so.” I’m hoping you will be able to say things like “but you can accomplish the same thing by doing this-and-that,” or “if you did such-and-so, you would have to deal with unexpected-something,” or possibly “well, yes, but I don’t think that’s especially useful/important,” et cetera.
A few capabilities that seem like they’d be useful to me, but which I cannot think of an obvious way to do under the current design, are (a) to be able to pass a partially constructed Forme.form as a parameter, and (b) to be able to access metadata about a form. There’s also (c), being able to build part of a Forme form, then leave the block, do something else, then come back and add to it, but that’s a lot like (a) without a context change, and I can’t think of a case where that would be really useful, instead of figuring out whatever it was before starting to build the form, and accessing the whatever inside the block.
I confess I’m having trouble coming up with specific examples for “Hey, XXX would be useful but isn’t currently possible,” so this might all be quite irrelevant, except for one; the input manifest I mentioned earlier.
frm = Forme.new
frm.form(obj, :action=>’/save’){ |f|
f.input(:field1)
…
end
sessionStorageVar = frm.manifest
sendToUser(frm.to_html)
Ah. I think I’ve thought of another possible usefulness that would be less feasible with the current system (I think): storing the form.
yaml.dump(frm)
anotherfrm = yaml.load(from_frm_storage)
anotherfrm.to_html #which perhaps instantiates the obj at this time, quite possibly creating a different form than the one it would have originally
Polka-dots and moonbeams. Can you do these things now? Do you think anybody would want to? If they did, would that be a bad idea? I am most interested in your reply. However, at the risk of stating the obvious, whatever you’re doing in Kiev is probably more important, and I sincerely hope, more fun. :)
Beta Was this translation helpful? Give feedback.
All reactions