I have a requirement whereby for guest checkout, I have to introduce a field which is populated via an AJAX call and then when user clicks on any option, the whole form of the guest checkout is submitted.
Does it make sense to use the existing Spring MVC form for guest checkout or use a separate form?Should we have a seaparate action configurable via Javascript for that form and how to handle the binding for the path?
If in the jslt the field is in the same form as the existing fields, then yes just add it to your Spring form.
The fact that this field is populated by an ajax call makes no difference for the POST.
Related
I'm hoping someone out there can help me understand how Stripe should work with Cakephp 3.
I have a form with the Stripe payment fields and a couple of fields for my cake app. From the Stripe documentation this seems to be an acceptable way to set it up.
The HTML is fairly standard, but note how every input for sensitive
data—number, CVC, expiration, and postal code—omits the name
attribute. By omitting a name, the user-supplied data in those fields
won't be passed to your server when the form is submitted. Each
element also includes a data-stripe attribute, to be discussed later.
I'm using cakephp 3 now which doesn't seem to allow me to remove properties from the HTML generated by the form helper. I can only make the 'name' property be blank. I queried this with Stripe support and they were a little noncommittal. They are generally very good but in this instance the answer seemed to be 'better safe than sorry.'
My main question is this: does it really matter if you don't use the form helper for Stripe fields. The main benefit i can find in the cake docs is that the CSRF component will act on those fields. I am using the CSRF component throughout my app, but since the Stripe fields aren't even sent to the server the CSRF component is irrelevant. Isn't it?
Here's an excerpt from the Cakephp manual:
The CsrfComponent works by setting a cookie to the user’s browser.
When forms are created with the Cake\View\Helper\FormHelper, a hidden
field is added containing the CSRF token. During the
Controller.startup event, if the request is a POST, PUT, DELETE, PATCH
request the component will compare the request data & cookie value. If
either is missing or the two values mismatch the component will throw
aCake\Network\Exception\InvalidCsrfTokenException.
I can still use the form helper for the few fields that do get submitted to the database, and just add the Stripe fields with HTML?
Does that make sense?
Stripe support did suggest having two separate forms, one for the cake data and one for the Stripe data, but since their docs say you can add the Stripe fields to a form that gets submitted to the server that seems a bit odd.
I would really appreciate some input on this as it seems even Stripe themselves aren't sure how to structure a cakephp payment form!
Yes raw HTML appears to be the way to go.
Here's what i did.
Used the form helper to start and end the form (This means form tampering and CSRF will work for your non Stripe fields)
Added the Stripe fields within the Cake form using HTML (I haven't tested the HTML fields to see if the form tampering works on them. I'll test that later and post back)
Used the Form helper to unlock the stripeToken field so it could be added to the form without the form tampering blackholing the request.
Once i set all this up I used echo debug($_POST) in my controller to see what the form was submitting to the server and the only Stripe field that was showing up was stripeToken.
So it appears to me that this is working as it should.
I am working on a project that would require some authorized users to 'Approve' or 'Reject' a request.
I would like these actions to be performed right from the user's inbox.
Is it possible to add more than one ConfirmAction that will be disabled once one of them is clicked. If yes, kindly provide a sample markup.
Gmail only supports a single action. If you specify more than one action in your markup, only the first will be rendered.
Thanks for describing your use case, though, we plan to add new action types and this is a legit request.
Is it possible to have a field in the current item be changed by clicking a URL? The field would be a choice field with predefined choices.
Such as if the item field is currently:
Status: 2
If a user clicks the link, the field would now be:
Status: 3
If not, is there any other way for a user to easily change a field in the current item without actually haveing to visit the item?
Thanks!
Not Out Of The Box (OOTB) - but you've a few options.
Write an ASPX page to do what you want
Use something like SPServices and javascript to update the list item via the web services.
Use the Client Object Model (2010 only)
By the way - changing stuff on a 'get' can be dangerous as you can do malicious things - for example imagine you have a page that deletes the users account without any prompting (exact example doesn't matter) - what if someone clicks on that link by mistake or even worse what about an email sent with an image with that page as source URL - simply viewing the email could delete the users account.
It's not possible by using a GET request, but SharePoint 2010 is offering a RESTful API to manage ListItems from any client
The REST API is located within the virtual WebServices folgder under each SharePoint Site.
http://YourSharePointSite/_vti_bin/ListData.svc.
To perform an update on SharePoint ListItems you have to create a PUT Request. For more information on SharePoints REST API you should have a look at this MSDN site, there are also a lot of samples linked from this article.
Thorsten
In our current prototype most the standard HTML controls are replaced by an applet, most important the form submission is triggered by the applet.
Is there a way to call an associated action on the server side much the same way as with
<h:commandButton action="#{ctrl.doit}"/>?
This article Applet and JSF Integration - example had the same question but not a suitable answer. The applet is a drop in replacement for a form from the viewpoint of the server. It fills dedicated (hidden) fields and submits - no direct communication to a server.
EDIT
So far, i understand there are these integration possibilities:
add a (hidden) UICommand and trigger it via JavaScript
Implement a UICommand of your own. As far as i understand, i'd define a hidden parameter for marking the applet as the form submit control, in the request processing cycle the UICommand implementation will find out and trigger the action. Maybe one should implement a virtual control (comparable to f:viewParam) as an endpoint for MethodExpressions.
Attach a listener, either to a (random) control or a more general event listener and do your stuff here. In this case, how is navigation done?
This is not possible without having a physical JSF view in the very same page which has the applet embedded. So, you should really at least have a <h:form> with a <h:commandButton> in the same page, if necessary hidden by CSS display: none;. This is simply because JSF needs to have a view state of that form in the server side, among others to prevent CSRF-like attacks. If having a physical <h:form> in the page is not a problem for you (which seems to be true in your particular case), then you can just let Applet fill the fields (if any) and click the button of the form using Applet-JavaScript communication.
Other than that, a simple servlet or a real webservice API like JAX-RS/JAX-WS is really the best way. JSF is a component based MVC framework and not a webservice framework. That's what my answer in that linked question is trying to make clear: use the right tool for the job.
What would be the best way to construct a contact form in Drupal 6 for each node of a particular type? I have some CCK nodes of type "profile" which have email address as a field. I want to have a view for each node with a contact form that users can fill out and send with their own email address as a return address (so that further contact is being done offsite).
Basically I just want that initial email contact to be done through my site, and when the recipient replies it just goes to the address that the sender entered when they filled out the contact form.
You might be asking yourself why I don't use the personal contact form that comes baked into Drupal. The issue is that the way my institution deploys their Drupal instances to use the local Kerberos logins, the user accounts it creates in Drupal do not have email addresses. They just get a basic skeleton account with username. I don't really want to force users to go through another hoop of editing their user account info, because they most likely just won't do it.
There is nothing to do particularly with node itself, all you need for this - is form with fields (from, to, subject, message) and custom submit handler for this form.
you can implement all this in custom module using forms API to create form and write custom submit for it. And in this submit you need to send email via drupal_mail() - take a look at this, it is provides examples as well. That topic can help you with forms.
Then, if you need to place this form within a node, you can do the following:
via hook_nodeapi, on "view" operation, add form you've created before, you can check for particular node_type and use existing field values (you mentioned cck field with email) to pre-fill form. So that every time user views node, he sees this form.
as logical continue of your task, I suggest it makes sense to take a look at menu system and create local task (tab) for the node, where you'll display email form.
In general, that's all. There are of course other ways of implementing this, however I think this one is the easiest for understanding.
Regards, Slava