Name that form!



  • I am in the process of learning Joomla in order to do some work for a client. Not having ever use it before (but still having half a clue about PHP MVC frameworks) I dived into their tutorial, built the demo MVC component and was fairly happy about how it all hung together (*). So I went about my business and started to build my version of a component that fulfills my needs, copying bits and pieces from the tutorial where needed, going out on my own when I had to.

    One of the things I borrowed was usage of a standard Joomla javascript function checkAll() which can be used to set all the check boxes in a form to be checked or unchecked. This worked well in the demo, but failed miserably in my code for no obvious reason. After wasting a couple of hours checking and rechecking my code and various help files etc I finally found the solution deep in the source code to this function - it is hard coded to the name of the form having to be "adminForm". Me in my sheer reckless bravado had named my form more along the lines of what it was meant to be doing.

    (*) I'm still not happy about the whole joomla (and other php frameworks) MVC structure being built around file, class and directory names all having to magically align in order for the system to work



  • @OzPeter said:

    (*) I'm still not happy about the whole joomla (and other php frameworks) MVC structure being built around file, class and directory names all having to magically align in order for the system to work
    It probably does that so __autoload() works.@OzPeter said:
    One of the things I borrowed was usage of a standard Joomla javascript function checkAll() which can be used to set all the check boxes in a form to be checked or unchecked.
    jQuery to the rescue!

    $('input[type=checkbox]').attr('checked', true);
    


  • Hey, if you think THAT's bad, try using the "built-in" TCPDF library...



    libraries/tcpdf/config/tcpdf_config.php, lines 36-46


    [code] // PLEASE SET THE FOLLOWING CONSTANTS:



    /

    * installation path (/var/www/tcpdf/)

    */

    define ("K_PATH_MAIN", "D:/Inetpub/wwwroot/_OPENSOURCE/tcpdf/");



    /


    * url path (http://localhost/tcpdf/)

    */

    define ("K_PATH_URL", "http://localhost/_OPENSOURCE/tcpdf/");[/code]


    So much for being "built-in", eh?



  • @Lingerance said:

    @OzPeter said:
    (*) I'm still not happy about the whole joomla (and other php frameworks) MVC structure being built around file, class and directory names all having to magically align in order for the system to work
    It probably does that so __autoload() works.
    I know why it works, but coming from a background of statically typed languages I think I'd prefer something that is checkable before runtime.



  • @OzPeter said:

    (*) I'm still not happy about the whole joomla (and other php frameworks) MVC structure being built around file, class and directory names all having to magically align in order for the system to work

    Not that I'm endorsing that setup, but isn't that what Ruby On Rails does? Their spin is that it's "convention rather than configuration". I really don't like doing things that way--I like having control over my naming and directory structure--but it's hardly unique to PHP frameworks, is it?



  • @OzPeter said:

    One of the things I borrowed was usage of a standard Joomla javascript function checkAll() which can be used to set all the check boxes in a form to be checked or unchecked. This worked well in the demo, but failed miserably in my code for no obvious reason. After wasting a couple of hours checking and rechecking my code and various help files etc I finally found the solution deep in the source code to this function - it is hard coded to the name of the form having to be "adminForm". Me in my sheer reckless bravado had named my form more along the lines of what it was meant to be doing.

    I've never used Joomla (dipped my toes in once and ran away), but does it by any chance work like ASP.NET, where every page has a server-side <form> element that contains all the content? I think ASP.NET does that to facilitate viewstate, but maybe Joomla has something similar?

    On a marginally related note: does ASP.NET's main form element mean that you can't have more than one form on an ASP.NET page (well, more than one form that has things like viewstate enabled)? Or is there some tricky maneuver to do so?



  • @OzPeter said:

    I know why it works, but coming from a background of statically typed languages I think I'd prefer something that is checkable before runtime.
    There are two things you can do to get around this: load another autoloader (there's an spl_ function for that) that maps the way you want, or include every class you could possibly use on each page to prevent the autoloader from firing.



  • In ASP.Net, you focus more on having AJAX controls than you do on having forms.  You can have any number of controls on a page that you want, and they can interact with each other and the server in innumerable ways.

     So in ASP.Net, you would be interested in making multiple AJAX panels rather than multiple forms.



  • @Lingerance said:

    There are two things you can do to get around this: load another autoloader (there's an spl_ function for that)
    I suppose it is the concept of the autoloader that I am annoyed with. In the simple MVC tutorial I am looking at there are 3 files called hello.php, another called hellos.php, 2 files called view.html.php. They all have to be named such and placed in specific directories in order for the autoloader to locate them as required be it model view or controller. As a result when working on a project my editor tends to collect a ton of open files all of the same name and it is hard to distinguish them apart without going back to the file system to see what directories they are coming from. Though its probably time for me to invest in better tools on the system I am now using (editing on OS X, deploying on Ubuntu) from my experience with ASP.net (but not the mvc version) I can happily locate and name the class files as befits my interpretation of how things should be laid out structurally.



  • @toth said:

    @OzPeter said:

    (*) I'm still not happy about the whole joomla (and other php frameworks) MVC structure being built around file, class and directory names all having to magically align in order for the system to work

    Not that I'm endorsing that setup, but isn't that what Ruby On Rails does? Their spin is that it's "convention rather than configuration". I really don't like doing things that way--I like having control over my naming and directory structure--but it's hardly unique to PHP frameworks, is it?

    I've used Zend and now joomla using php but I doubt the magical layout is restricted to just php. Another aspect of it that I have had fun with is that the routing of joomla is not all that well documented and what documentation there is has come out of a forum thread that basically asked "is this how the routing works?". Throw in some arbitrary (or so it seems) convention that controllers on the back end should have 's' appended to their name and you are really off to the races!



  • @hoodaticus said:

    In ASP.Net, you focus more on having AJAX controls than you do on having forms.  You can have any number of controls on a page that you want, and they can interact with each other and the server in innumerable ways.

     So in ASP.Net, you would be interested in making multiple AJAX panels rather than multiple forms.

    You can use traditional forms, but those lead to traditional postbacks, which lead to traditional users-getting-pissed-and-leaving.

    That said, I don't know if there's one viewstate-per-form, or just one per-page. My guess is the latter. But if you're coding your pages that way, and you don't care about postbacks, just let ASP.net do its thing and don't worry about it-- if you meddle you'll be as likely to muck things up as not.



  • @toth said:

    On a marginally related note: does ASP.NET's main form element mean that you can't have more than one form on an ASP.NET page (well, more than one form that has things like viewstate enabled)? Or is there some tricky maneuver to do so?
    Yes, you can only have one form that has ASP.Net magic applied to it.  However, once you let go of a form having any meaning whatsoever other than being a container for the stuff on the page, then it doesn't matter.  The first questions I usually get when poeple from other environments find out about this rule is something along the lines of "well then, how do you make a search form?"  The answer is, you don't -- you make a search control, or you put the search bar in the master page.



  • @OzPeter said:

    I suppose it is the concept of the autoloader that I am annoyed with. In the simple MVC tutorial I am looking at there are 3 files called hello.php, another called hellos.php, 2 files called view.html.php. They all have to be named such and placed in specific directories in order for the autoloader to locate them as required be it model view or controller. As a result when working on a project my editor tends to collect a ton of open files all of the same name and it is hard to distinguish them apart without going back to the file system to see what directories they are coming from. Though its probably time for me to invest in better tools on the system I am now using (editing on OS X, deploying on Ubuntu) from my experience with ASP.net (but not the mvc version) I can happily locate and name the class files as befits my interpretation of how things should be laid out structurally.
    I think this is more a side-effect to the severe separation that MVC wants. To do one thing you'd need a model class, and controller class and a view file/class. To enforce this they make each part its own file. I do AJAX with JSON-RPC and the autoloader is a good friend there (directory structure matches the namespace, so session\SessionManager is in classes/session/SessionManager.php).



  • @Jaime said:

    Yes, you can only have one form that has ASP.Net magic applied to it.  However, once you let go of a form having any meaning whatsoever other than being a container for the stuff on the page, then it doesn't matter.  The first questions I usually get when poeple from other environments find out about this rule is something along the lines of "well then, how do you make a search form?"  The answer is, you don't -- you make a search control, or you put the search bar in the master page.

    What about simply clicking enter to submit the part that I'm using? I have never used ASP.NET, but that is the bug (or "feature") I'm most familiar with on many pages that use it. I don't care on what page it will really redirect me to, I just want that pressing enter on username or password field (or at least on password) <will attempt to login. Or when I enter something in search field and press enter, I get the search results etc. Currently pressing enter results in more or less undefined behavior.</p>

    Some of the examples I found seem to suggest that the only way to archive that is by using JS. Not exactly user friendly system...



  • @Buzer said:

    @Jaime said:
    Yes, you can only have one form that has ASP.Net magic applied to it.  However, once you let go of a form having any meaning whatsoever other than being a container for the stuff on the page, then it doesn't matter.  The first questions I usually get when poeple from other environments find out about this rule is something along the lines of "well then, how do you make a search form?"  The answer is, you don't -- you make a search control, or you put the search bar in the master page.

    What about simply clicking enter to submit the part that I'm using? I have never used ASP.NET, but that is the bug (or "feature") I'm most familiar with on many pages that use it. I don't care on what page it will really redirect me to, I just want that pressing enter on username or password field (or at least on password)

    Some of the examples I found seem to suggest that the only way to archive that is by using JS. Not exactly user friendly system...

     

    In that instance you would probably put your controls inside a Panel, this allows you to set a Default button to the group so no matter what control has focus in that panel if you hit enter one the onclick event for yous nominated button is clicked.

    Im pretty sure that this will add something similar to the JS examples that you found... however its setting one attribute on a container as opposed to fannying around with JS so its pretty simple and takes all of the leg work out for you.



  • @Buzer said:

    @Jaime said:
    Yes, you can only have one form that has ASP.Net magic applied to it.  However, once you let go of a form having any meaning whatsoever other than being a container for the stuff on the page, then it doesn't matter.  The first questions I usually get when poeple from other environments find out about this rule is something along the lines of "well then, how do you make a search form?"  The answer is, you don't -- you make a search control, or you put the search bar in the master page.

    What about simply clicking enter to submit the part that I'm using? I have never used ASP.NET, but that is the bug (or "feature") I'm most familiar with on many pages that use it. I don't care on what page it will really redirect me to, I just want that pressing enter on username or password field (or at least on password)

    Some of the examples I found seem to suggest that the only way to archive that is by using JS. Not exactly user friendly system...

    To answer the meta-question, instead of the question, do you honestly believe the designers of Microsoft wouldn't have thought of that? It's significantly more likely that the examples you've found were written by idiots, than that it never occurred to Microsoft's engineers that someone might need to keyboard-submit more than one form on a particular page.

    For the record, yes, you can group controls so that they behave like a traditional (meaning: plain HTML) form. You make one control group for your search box and search submit button and another for your other form. ASP.net handles the nitty-gritty.



  • @blakeyrat said:

    For the record, yes, you can group controls so that they behave like a traditional (meaning: plain HTML) form. You make one control group for your search box and search submit button and another for your other form. ASP.net handles the nitty-gritty.


    Quick question from someone who never did ASP.net... is there a single *ing way to make an "application" in it that still works (including such tiny impotant details like Enter submitting the right formfields) when browser has disabled javascript?



  • @bannedfromcoding said:

    is there a single *ing way to make an "application" in it that still works (including such tiny impotant details like Enter submitting the right formfields) when browser has disabled javascript?
     

    I'm very green to .Net, but I'm assuming Wonko's Panel solution does just that.

    Submitbuttons get submitted, see, and you don't strictly need javascript to differentiate between logical groups of fields of the same explicit form. A server knows which button was clicked by virtue of a certain submitbutton being defined in the POST request.

     

    PS.
    You can say fuck here. It's okay.



  • @dhromed said:

    PS.
    You can say fuck here. It's okay.

    Not it is not, young man, I'll wash your mouth with soap after saying such nasty words an you get no supper tonight, now off you go.



  • @bannedfromcoding said:

    @blakeyrat said:

    For the record, yes, you can group controls so that they behave like a traditional (meaning: plain HTML) form. You make one control group for your search box and search submit button and another for your other form. ASP.net handles the nitty-gritty.


    Quick question from someone who never did ASP.net... is there a single *ing way to make an "application" in it that still works (including such tiny impotant details like Enter submitting the right formfields) when browser has disabled javascript?

    Again, yes of course. The engineers who build ASP.net aren't retards. Shocking but true.

    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.



  • @dhromed said:

    I'm very green to .Net, but I'm assuming Wonko's Panel solution does just that.

    Submitbuttons get submitted, see, and you don't strictly need javascript to differentiate between logical groups of fields of the same explicit form. A server knows which button was clicked by virtue of a certain submitbutton being defined in the POST request.

    Erm. If you have a single form, with more than one submit button, and hit Return in one of the form text fields, the first submit button is the one that gets posted. I just checked, that applies even in IE, and even if you try to create subgroups with fieldset tag. So, ass-uming that you really always have jusr One Humongous ASP.Net Form, and the Javascript return-key handler isn't available, no matter which field you hit Return, first button gets "clicked".

    Damn, you're actually making me want to install this whole mess to experiment.

    @dhromed said:

    PS.
    You can say fuck here. It's okay.

    Sure, but why waste a perfectly good fuck in here?


    @blakeyrat said:
    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.

    Yeah, and also to cater to people using limited-access devices, text browsers, and such... well, also all these "Aaargh, Google Analytics" paranoiacs.



  • @bannedfromcoding said:

    @blakeyrat said:
    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.

    Yeah, and also to cater to people using limited-access devices, text browsers, and such... well, also all these "Aaargh, Google Analytics" paranoiacs.

    Fortunately, this is becoming less of an issue to mobile devices, almost all of which now support JS. But good point.

    To your second point, GA can track using pixels, so disabling JavaScript doesn't do jack there. (It does prevent Omniture and probably WebTrends from working, though. Doesn't do anything to stop Test&Target.) If they're paranoid about web analytics, they need to block it at the Hosts file.



  • @Buzer said:

    Some of the examples I found seem to suggest that the only way to archive that is by using JS. Not exactly user friendly system...
    You can do this with multiple iframes too.



  • @blakeyrat said:

    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.
    I run noscript because some sites like to do assfuckingly retarded shit like pull need feeds from twitter 4 times a second, per page and I tend to open 5 or so of those pages for reading later before I realize they do that shit. Or they'll popup windows whenever I click anywhere on the page, or they'll disable selecting (which I use as a reading aide), or they'll shove a really complicated function into the mouse move event and everything slows to a crawl on a dual code 2.88ghtz machine with 4GB of RAM.



  • @Lingerance said:

    @blakeyrat said:
    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.
    I run noscript because some sites like to do assfuckingly retarded shit like pull need feeds from twitter 4 times a second, per page and I tend to open 5 or so of those pages for reading later before I realize they do that shit. Or they'll popup windows whenever I click anywhere on the page, or they'll disable selecting (which I use as a reading aide), or they'll shove a really complicated function into the mouse move event and everything slows to a crawl on a dual code 2.88ghtz machine with 4GB of RAM.

    What the fuck websites are you visiting? Even porn sites aren't THAT bad.



  • @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    Of course, from my experience, the main reason people turn off JavaScript is purely so they can bitch about how many web sites don't work with JavaScript turned off.
    I run noscript because some sites like to do assfuckingly retarded shit like pull need feeds from twitter 4 times a second, per page and I tend to open 5 or so of those pages for reading later before I realize they do that shit. Or they'll popup windows whenever I click anywhere on the page, or they'll disable selecting (which I use as a reading aide), or they'll shove a really complicated function into the mouse move event and everything slows to a crawl on a dual code 2.88ghtz machine with 4GB of RAM.

    What the fuck websites are you visiting? Even porn sites aren't THAT bad.





    You'd think with your post count you'd know better... ;)



  • @blakeyrat said:

    What the fuck websites are you visiting? Even porn sites aren't THAT bad.

    Depends on the level of weirdness, the weirder the sexually explicit content the worse is the codeing, so my guess is furry sexually explicit content website as they don't seem to think that good programming is a must.

    Regards



  • @bannedfromcoding said:

    If you have a single form, with more than one submit button, and hit Return in one of the form text fields, the first submit button is the one that gets posted.
     

    Oh, that's totally true, of course, so the issue of which button gets focus after the page's loaded still stands.

    You can click, though.



  • @dhromed said:

    You can click, though.
    Are you a socialist or a communist!?!?!? Suggesting that I use a mouse .. What is the world coming to?



  • @blakeyrat said:

    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.

    This page spikes my load so much that X freezes



  • @Lingerance said:

    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.

    This page spikes my load so much that X freezes

    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?



  • @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.

    This page spikes my load so much that X freezes

    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?

    BTW, that site has an interesting definition of "free." Here, I ripped all the icons from World of Warcraft! They're free! Use them for whatever! Blizzard won't sue you, honest!!



  • @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.
    This page spikes my load so much that X freezes
    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?

    Same here, I tried it in FireFox, and then (just to give it the worst case) IE too, and nothing.



  • I'm not getting anything either.

    It's the banners, most likely, but they get swapped out so we can't reproduce it reliably.

    I guess Ling also uses a much lighter computer than the rets of us, as Linux mostly runs perfectly fine on old crap.



  • @serguey123 said:

    @blakeyrat said:

    What the fuck websites are you visiting? Even porn sites aren't THAT bad.

    Depends on the level of weirdness, the weirder the sexually explicit content the worse is the codeing, so my guess is furry sexually explicit content website as they don't seem to think that good programming is a must.

    Regards

     

    Furries are practically mainstream these days. You can find them on all sorts of TV shows.

    You gotta get _specific_ for the really weird stuff / bad programming. 



  • @EJ_ said:

    You gotta get _specific_ for the really weird stuff / bad programming. 
     

    Like, "Horse speculum" ?



  • @DescentJS said:

    @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.
    This page spikes my load so much that X freezes
    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?

    Same here, I tried it in FireFox, and then (just to give it the worst case) IE too, and nothing.

    It was most likely a banner ad as I had someone else confirm they were getting issues when I posted it and I'm not getting any now.


  • @Lingerance said:

    @DescentJS said:

    @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.
    This page spikes my load so much that X freezes
    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?

    Same here, I tried it in FireFox, and then (just to give it the worst case) IE too, and nothing.

    It was most likely a banner ad as I had someone else confirm they were getting issues when I posted it and I'm not getting any now.

    Well, I hate to break this to you, but if some moron writes while(true){} in a Flash ad creative, it behaves just as badly in every browser. (The sad thing is Flash has about 40,000 different ways to time events, and yet some morons still write while(true){}.)

    Not a browser issue at all, it's a Flash issue.



  • @blakeyrat said:

    @Lingerance said:
    @DescentJS said:

    @blakeyrat said:

    @Lingerance said:
    @blakeyrat said:
    hat the fuck websites are you visiting? Even porn sites aren't THAT bad.
    This page spikes my load so much that X freezes
    It... it does? It's not even a blip on my system. (Chrome 6, Windows 7, Core 2 Duo.) Do you have Java installed? Maybe there's a Java applet I'm not seeing?

    Same here, I tried it in FireFox, and then (just to give it the worst case) IE too, and nothing.

    It was most likely a banner ad as I had someone else confirm they were getting issues when I posted it and I'm not getting any now.

    Well, I hate to break this to you, but if some moron writes while(true){} in a Flash ad creative, it behaves just as badly in every browser. (The sad thing is Flash has about 40,000 different ways to time events, and yet some morons still write while(true){}.)

    Not a browser issue at all, it's a Flash issue.

     

    unfortunately, that can be said of a lot of problems with webpages.


  • Garbage Person

    @Jaime said:

    The answer is, you don't -- you make a search control, or you put the search bar in the master page.
    At which point the Master Page has a server-side form in it, and blows up at runtime until you go jiggle the HTML to not suck.


  • Garbage Person

    @bannedfromcoding said:

    Quick question from someone who never did ASP.net... is there a single *ing way to make an "application" in it that still works (including such tiny impotant details like Enter submitting the right formfields) when browser has disabled javascript?
    Oddly enough, I was hacking up some raw HTML shit Sunday night and noticed that.... By fucking god, Firefox is submitting ALL the form fields from ALL the forms on the page to the action of the form you actually activated.

    Let the form processor sort 'em out.



  • @blakeyrat said:

    Well, I hate to break this to you, but if some moron writes while(true){} in a Flash ad creative, it behaves just as badly in every browser. (The sad thing is Flash has about 40,000 different ways to time events, and yet some morons still write while(true){}.)

    Not a browser issue at all, it's a Flash issue.

    That would be an impressive feat, seing as how I don't install flash for that very reason.


  • @Weng said:

    Oddly enough, I was hacking up some raw HTML shit Sunday night and noticed that.... By fucking god, Firefox is submitting ALL the form fields from ALL the forms on the page to the action of the form you actually activated.

    Not seeing this here... you sure that you don't have some missing </form> there?

    Of course, I tested in 3.6.10. They broke a ton of stuff, from the page renderer to the JS api in 4.0 betas... not letting that thing nowhere near my PC.



  • @Lingerance said:

    You can do this with multiple iframes too.

    Sir, talking about iframes is not a thing we tolarate on these premises. Now please step away from the compiler and nobody gets hurt.



  • @bannedfromcoding said:

    They broke a ton of stuff, from the page renderer to the JS api in 4.0 betas...
     

    The 4ß is still in poor shape.

     

    They have this internal inspecter which, um, vomits all over itself the minute your start it, and then you have to kill FFX. Maybe it's a conflict with Firebug, maybe it's a oncflict with a preexisting 3.6 installation or summat, but I'm only 7% confident that it's going to be better than Firebug.

    Hell, maybe FFX4 incorporates Firebug natively, but I sure wasn't able to see that because al its windows and palettes would just blink with some infinite redraw loop.

     

    Interface bonus: Installing the beta side by side with 3.6 hides your menubar in 3.6 as well. It's made quite insightful just how little I actually use that thing, and I wholeheartedly welcome the killing of menu bars, and will fiendishly lambast all those who resist change and whine I WANT MY MENUZ BAK.



  • @Shortjob said:

    @Lingerance said:
    You can do this with multiple iframes too.

    Sir, talking about iframes is not a thing we tolarate on these premises. Now please step away from the compiler and nobody gets hurt.

    But... but... secure multi-mediation is the future of all webbing!


Log in to reply