Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Root826005y@ScriptCoded Vanilla only.
I will eventually rewrite the entire frontend in (probably) React, but with a hard launch date in just a few weeks and this feature being a blocker for others, I just don't have the time.
I may very well end up hacking the entire thing together in JS if I can't figure out a proper railsy way of doing it. (I have an idea, but it adds unwanted db bloat.) -
I don't think I've ever actually used a form tag before. (EDIT: Outside of school)
I create any elements I want, style them and place them anywhere in the document I want, then submit via ajax, or more recently, fetches.
Forms suck absolute cock'n'balls. -
@AlgoRythm Form might still be worth using. For example, you can just bind submit with a preventDefault and then any submit action such as a submit button or an enter keypress will submit it. Also, might be worth it for SEO, scraping and semantics.
-
@ScriptCoded Forms have equal downsides to upsides. While friendly bots like scrapers understand them well, so will unfriendly bots like spammers.
I would only use a form if it was required of me. -
Root826005y@norman70688 Here's a redacted screenie (:
It was a quick page, and i'm not a designer, so don't hate on the styling too much.
"Level #" is an arbitrary container, and has no associated db object. All of the pink, green, and orange cards have their own tables, as of course does the challenge itself. The pink and green cards have a hidden `level` field, which maps to the level container they're in. The issue is that I"m using Rails' `form.fields_for` helper for each section, which renders the associated partial for every single goal/reward record associated with the parent object, not just those with matching level numbers. I don't know how to filter them yet, or if I need to find a different approach. Thus every section renders all of them, so saving will triplicate everything.
Actually, this gives me an idea. It's dirty, but should work. (`form.fields_for :goals_level_1` and then define the associated method on the model... unless it uses AR magic instead of public methods.) -
ojrask2915y@AlgoRythm way to go losing all accessibility and usability benefits of HTML forms. If you need such complex forms, maybe it might be a good time to think about your data structures and application flows instead. Are there specific parts that make you avoid forms?
-
@ojrask Probably all the poor code in tutorials and schooling that they have been used in, honestly. That and the assumptions the form makes. I have telling code specifically NOT to do something (i.e. e.preventDevault), because it breeds unexpected behavior. Hours of googling later, you find that a form did something on it's own and that's why your simple little input form did something you didn't want.
I'm sure they have plenty of place in the web world. Almost everything does. But I don't tend to make applications that find that use. -
ojrask2915y@AlgoRythm some form elements are outdated a bit yes, but I would rather take that hit and acquire platform defined well known interactions and features, rather than doing it all from scratch.
-
@ojrask What's undefined or even not-well-defined about writing a post request based on the value of a text box?
It's more common technology since forms are HTML-only and text boxes/ post requests are present in many other systems too, like Android, iOS, WPF, Qt, Etc. -
@Root maaaaybe i am not properly understanding(99 percent of the time this is the case) but I had a similar issue in which a form had to provide input items from data sources external to the form model for which I was working with. The solution that I did was populate the form fields from an api resource that points to the other model so that it can be submitted with the form thus eliminating the need for them to be nested.
Am I making sense? Even from reading what I wrote I did not make any sense........I am having a hard time trying to explain myself :( But hey! you a good dev :D you will figure this out i am sure of it! -
Root826005y@AleCx04 If I'm understanding correctly, you're a) rendering a rails html form with populated data, b) fetching additional data from an api, c) overriding the default form submit in JS to post that other data to an API, and if that succeeds, submitting the form?
That sounds like it would really complicate validation -- or at least the normal form's validation. It also sounds like it would complicate new record creation since you'd be creating children before the parent. I could hack it to work, though 🤔 -
Root826005yI finally got it working! yayayay.
After much fighting and swearing, I looked at the source of the `fields_for` helper, and discovered it accepts a collection, so I can have it display whichever ones I want using the `goals_for_level_#` hack I mentioned above.
No clue if these will actually save or not, but... progress! -
remove32595yHTML form magic strikes again... Who knows what will happen between the fortress walls of Castle <form><\form>
I fucking hate HTML forms! Especially representing bloody nested objects within them!
Fighting with html forms has taken at least 80% of my time over the past three features. Why can't I just do this via API? It would be soo much freaking simpler! ugh.
But today.
Today is not going to be a good day.
I not only get to expand a complicated vanilla form with with one nested object today, I get to expand it to include three nested objects. Normally this wouldn't be a problem because it's just moving elements around, but two of those nested objects need to be broken up and combined into three+ segments each. I have no idea how to even approach this.
ugh.
rant
html forms
root likes talking in third person
root hates html forms
root likes apis