#1
Hello Trongate users!
I am new to javascript and php and would like some advice on the aforementioned subject.
below is the js code I use to hide sections of the form

I use Trongate module generated code for my view (create)
At the beginning of the form code I use:

When I reach the last page of the form and I click the Submit button, the js function is called but the page just reloads.
The first 'card' ( div) of the form shows but no validation errors show nor is any form data is past through to the controller.
Any pointers will be appreciated.

Cheers!
#2
Hi Keepcalm,

I think using the API manager to send data to endpoint methods will solve your issues.

Suggest you read up on it in the docs and watch a few YT vids DC has already done. Another is to create a module relation and study the code generated to see how it's done.

Pitty you're not a SCA member, as it's all explained at speedcodingacademy.com
#3
Hi Dafa,
I solved this by putting the form opening and closing tags outside of the divs of the various cards and used inputs of type button to trigger the js to show/hide the cards, thus foregoing the javascript for form submission.
This way I don't have to worry about saving the values between each step and I get my validation errors as normal.
I have looked at the API documentation, but like I have said before, I am new to web development so I try to look for the simplest way to get things done.
That is why I love Trongate, it's generated code has taught me a lot about php and while I do ask questions when I get stuck, I usually get great pointers from yourself and djnordeen . To me part of the joy of learning is trying to work things out when up against a (virtual) wall. I will join the SCA forum eventually, but I want to at least complete the major parts of my current project as I am known to be poor with time management and I do get easily distracted in forums, that is also why I love the Help Bar here, no distractions . Again...Thank you for your support DaFa.

Cheers!
#4
Hi KeepCalm,

I'm glad you have found a solution to your long form by hiding sections on cards. It is worth learning the API in full, with it's end points, before and after hooks and security - a real time saver once you get the grasp of it all, with no need for jQuery. I would recommend installing 'postman' or my preference, DC's module 'postperson' from the Module Market to play with the Trongate API and api.json in the assets folder of each module.

You have the right mindset with learning by doing and a lot of others here would do better by your example. Never be afraid to look at the code in the Trongate engine or it's helpers to see what is going on.

I've turned off the contact form on the SCA forum since I reopened it for you the other day because I was getting flooded with Chinese and Russian spam - let me know if you want in and I'll reopen it.

Cheers,
Simon
#5
Hi Dafa,
Sorry for the spam on the SCA forum, I will let you know when I want to register as it seems the API has a lot more functionality than I initially assumed.
I have just re-written my project to work with foreign key constraints without errors, and now my next update is to add filtering to the results by using custom date ranges, set in the manage view. (I can hear your voice saying "Use the API Luke" lol).
As usual, I will be trying to use what I have learned so far to get this done, then my last set of updates would be to create views and stored procedures in mariadb to generate reports and hopefully get them exported to pdf and MS Excel.
I must say that although new to php and html development, Trongate makes the php quick to implement and it is actually figuring out how to get the html to display what I want to implement very challenging, especially since I don't know javascript.
I am learning and loving Trongate more and each day!

Cheers!
#6
Hi KeepCalm,

That's fine, the spam bots that crawl the SCA forum are a pain but I keep them under control.

hahaha I like your Star Wars connection ? The API was written mostly for JS devs and if you're a hardcore PHP dev, you can get by without using it.

Sounds like you are getting a good grip of PHP and JavaScript. Stored procedures are handy to have in your database. I'm writing an invoicing system at the moment, that will output to PDF and I may add Excel (csv, xlsx) too. I've managed to contain it all in one super-module, even the vendor libraries, so in theory, it can be bundled up into a zip file and uploaded to the Trongate Module Market for any easy install to any project - stay tuned for that ?

So glad you are enjoying Trongate!