We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49407
    • 159 Posts
    Here is my chunk...

    [[!FormIt? 
        &hooks=`formit2db,redirect`
        &prefix=`xyzinvite_`
        &packagename=`inviterequester`
        &tablename=`requests`
        &autoPackage=`1`
        &emailTpl=`irequestEmailChunk`
        &emailTo=`[email protected]`
        &redirectTo=`20`
        &validate=`email:required:email`
    ]]
    
    <div id="inviteFormContainer" class="fullWidth">
        <div class="center width600px height160p centerText inviteWraper">
            [[!+fi.validation_error_message:notempty=`<p class="textGlow">[[!+fi.validation_error_message]]</p>`]]
            [[+fi.error.error_message]]
    
            <form name="form" action="[[~[[*id]]]]" method="post" class="form">
                <input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" />
                
                [[!+formit.recaptcha_html]]
                [[!+fi.error.recaptcha]]
                
                <li class="fieldOuterBox">
                    <input placeholder="Enter your email..." type="text" class="css-input" name="email" id="email" value="[[!+fi.email]]">
                    <a type="submit" name="submit" class="btn" onclick="form.submit();">Request Invitation</a>
                </li>
            </form>
            <p class="textGlow">
                [[*content]]
            </p>
        </div>
    </div>
    



    Here is the result of clicking the submit button...

    [2014-12-08 03:15:31] (ERROR @ /index.php) Could not load class: Requests from mysql.requests.
    [2014-12-08 03:15:31] (ERROR in formit2db Hook @ /index.php) Failed to create object of type: Requests

    I am completely lost.
    What is the class: Requests?
    Why can't it load the class: Requests?
    Why is it trying to create object of type: Requests?

    This question has been answered by multiple community members. See the first response.

    [ed. note: aaronkent last edited this post 9 years, 4 months ago.]
      • 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
      • Try the latest version of FormIt2db. The package generation is executed now in FormIt2db too. Before it was only active in db2FormIt.
        • discuss.answer
          • 49407
          • 159 Posts
          Jako, I am using the newest version. I updated it yesterday.

          Have autoPackage set to true.

          sottwell, thanks for the links. Studying now.

          I can't believe how convoluted database access is. Wow. I'm a custom to much simpler abstraction layers.
            • 49407
            • 159 Posts
            I don't understand if the schema is supposed to generate by setting autoPackage to true or false?

            Both ways I get errors.

            Set to true...

            [2014-12-09 01:56:50] (ERROR @ /index.php) Path specified for package inviteMe is not a valid or accessible directory: /home/m1chaelkent/public_html/core/components/inviteMe/model/
            [2014-12-09 01:56:50] (ERROR @ /index.php) Could not load class: Requests from mysql.requests.
            [2014-12-09 01:56:50] (ERROR in formit2db Hook @ /index.php) Failed to create object of type: Requests

            Set to false...

            [2014-12-09 01:57:51] (ERROR @ /index.php) Path specified for package inviteMe is not a valid or accessible directory: /home/m1chaelkent/public_html/core/components/inviteMe/model/
            [2014-12-09 01:57:51] (ERROR @ /index.php) No class specified for loadClass
            [2014-12-09 01:57:51] (ERROR in formit2db Hook @ /index.php) Failed to create object of type:

            Yes, there seems to be no object type specified.

            Basically the auto create schema is not working. The core/components dir is set at 0777

            What else could cause this to fail?

            I have wasted 3 days on this so far and it's completely absurd that it is this difficult to use my own tables in the DB.

            Am extremely frustrated and put off by MODx now.
              • 3749
              • 24,544 Posts
              On many servers 777 won't work. Give 755 for directories and 644 for files a try.

              This has nothing to do with MODX, btw. It really looks like the file not readable either because of permissions or ownership.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              • Maybe you are lost in a name convention problem with your package name. It should be all lowercase as far as I know.

                But that is not really well documented (found a few tipps in a forum thread: http://forums.modx.com/thread/81116/creating-a-custom-resource-class#dis-post-446925).

                Maybe the package name should be automatic converted to lowercase in FormIt2db/db2FormIt.
                  • 49407
                  • 159 Posts
                  Thanks for all your help guys.

                  Although these plugins you both have written work well for other uses, I need to develop some use specific snippets that do things in slightly different ways to achieve my end goal.

                  I did get this working, Jako, but It's just not quite what I need for my application. Although, I will be using this to reference from. I found the JSON input format option interesting.

                  I think the biggest turn off for me is the lack of doc/examples for the methods. Also, I came into this thinking that the existing extras would suit what I need, so my expectations were lofty. I'm just going to have to keep studying the API docs so I can become more proficient with the API.

                  I've already developed one snippet using both of your extras as usage examples for various modx methods, Jako, BobRay.

                  I really like the concept of NewsPublisher but, I need something that only allows a single post per day per "story". Plus a custom front end dashboard for the writers. It's going to take a month to get what I want just out of the snippet that manages the stories and the daily entries for those stories.

                  Thanks again to all of you!
                    • 3749
                    • 24,544 Posts
                    Just thinking out loud, but if you can identify the "story" resource and the posts based on it, you could check the month of the most recent post against the current month, print a "Sorry, only one post per month is allowed -- you're submission will not be saved" message at the top of the NewsPublisher page (or wherever) if they're the same, and set a session variable that you check before allowing a new post to be saved. The code that prevents the save could go in a plugin attached to one of the events fired by the resource/create processor.

                    In theory (IIRC), the save is aborted if the plugin returns false or an array (i.e. anything but true), but I'd test that first to make sure it works.

                    If the return is false, I think the save aborts silently. If it's an array, the members of the array are treated as error messages:

                    return array(
                      'Your post cannot be saved because only one post is allowed per month',
                    );


                    I've never actually tried this, but it's supposed to work. I'm not sure if the error message is displayed or sent to the error log, or what.

                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                    • discuss.answer
                      • 49407
                      • 159 Posts
                      Quote from: BobRay at Dec 11, 2014, 04:05 AM
                      Just thinking out loud, but....

                      If the return is false, I think the save aborts silently. If it's an array, the members of the array are treated as error messages:

                      return array(
                        'Your post cannot be saved because only one post is allowed per month',
                      );


                      I've never actually tried this, but it's supposed to work. I'm not sure if the error message is displayed or sent to the error log, or what.


                      It's actually once per day but I see your solution. I think I would like it better to disable the "add post" button unless the result of postedToday() returned false, then use your solution for backup if someone "hacked" the button.

                      Each story has a timestamp in last_post field so they can post an update to multiple stories in a single day but not multiple updates to a single story in one day. It's kind of intricate, but it will really provide a nice reading flow as a result, paginated by day. Comments will be open for each post 24/7 if they writer enables comments. They will also be allowed to moderate their own stories' comments but not other people's stories' comments.

                      I have my work cut out for me, Bob.