We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I got tired of cluttering up my main CSS file with styling for all the different forms a site might have. So I added a bit of modification to eForm (eFormCSS):

    # set eForm CSS file
    $eFormCSS = isset($eFormCSS)?$eFormCSS:'';
    if($eFormCSS != '') {
      $eFormCSS = $modx->config['base_url'] . $eFormCSS;
      $modx->regClientCSS($eFormCSS);
    }
    

    So now in my eForm(CSS) snippet call, I can add
    &eFormCSS=`assets/snippets/eform/contact.css`

    or wherever else I may want to keep my css, in the assets/templates/mytemplate/styles folder for example.

    I also added a line to the eform params so it shows up in the debug:
    // eForm Params
    eFormCSS => $eFormCSS,
    vericode => isset($vericode)? $vericode:"",
    formid => isset($formid)? $formid:"",
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 30223
      • 1,010 Posts
      Susan, why don’t you simply include a style block in the form template if you don’t want it to be in your main css file?

      Another option would be to use the AddCssWidget snippet and a TV which allows you to add extra stylesheet(s) without hacking eForm.
      • Yeah, but that means another TV/snippet, and I don’t like having css code in my content. But your suggestions are all fine if you’re not as lazy as I am.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
        • Inline style blocks are technically not valid... I’m on the fence about whether or not you should bundle in the ability to bundle in the style registration (and leaning towards doing so). Requiring an additional TV + a Snippet isn’t exactly easy for setting up. A small purpose-built plain old addCSS widget would make sense much like UltimateParent ... basically a config-free utility snippet.

          Ditto and Wayfinder handle their CSS needs internally and I think I lean towards making this an optional/default parameter for eForm, too. smiley
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 16429
            • 254 Posts
            Quote from: sottwell at Nov 08, 2006, 08:19 AM

            I got tired of cluttering up my main CSS file with styling for all the different forms a site might have.
            I think that all the forms on a site must be styled in a consistent way, why do you want different styles for them?
            Users can be lost trying to understand this.
            In case you speak about things like width because you’ve forms on the content area and forms let’s say in a sidebar, you can have great differences using group declaration and descendant selectors.
            No?
              kudo
              www.kudolink.com - webdesign (surprised?)

              [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
            • Definitely, but for a site with a single form, or a self-contained template to be distributed for use in a variety of sites, the ability to register css automatically without having to answer a bunch of questions as to why the form looks so bad sure is handy.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 30223
                • 1,010 Posts
                Quote from: rthrash at Nov 08, 2006, 03:00 PM

                Inline style blocks are technically not valid...
                I know, technically speaking you are quite correct, but personally I’m not too bothered about it in this case. Separation of presentation and data is in the case of a form not really an issue (in my opinion). Form elements may carry data from one place to another but form elements in my interpretation are themselves presentation. Having a style block inside the body of a form doesn’t do an injustice to the thought behind standards as far as I’m concerned.


                I’m on the fence about whether or not you should bundle in the ability to bundle in the style registration (and leaning towards doing so). Requiring an additional TV + a Snippet isn’t exactly easy for setting up. A small purpose-built plain old addCSS widget would make sense much like UltimateParent ... basically a config-free utility snippet.

                Ditto and Wayfinder handle their CSS needs internally and I think I lean towards making this an optional/default parameter for eForm, too. smiley

                I do agree with you there. I wrote the addCssWidget snippet in response to a question elsewhere in the forum and using it ithe way it’s set up has it’s use but is perhaps not the most appropriate here. Come to think of it, it’s easy to adapt it so that it can be used standalone as well. I think I’ll make some changes...

                Getting eForm to handle styles internally and thus conform to a style (pardon the pun) similar to Ditto and Wayfinder is a good idea. I’ll take that on board and implement it in eForm.
                  • 32963
                  • 1,732 Posts
                  Susan,

                  Why not use chunks or just create snippet to include the style sheet using $modx->regClientCSS()? Or maybe include the css file along with your form template?

                  {{ContactCss}}
                  [[eForm?...]]
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.