How to get form field array in play framework - groovy

I'm using groovy to render templates in Play framework. I have a checkbox inside a list loop:
<input type="checkbox" name="chkUser[]" id="chkUser{users.getId()}" value="${users.getId()}">
How can i get the state of the checkbox array in Controller page.

Came across this a couple of monthes ago. It seems you can use find those back in controller using :
public static myFormFunction(boolean[] chkUser) {
...
Not sure of it and I cannot check this right now.
Take a look at the official documentation.

It can be achieved using hidden fields for every checkbox.
<input type="hidden" name="HdChkUser${users.getId()}">
<input type="checkbox" name="ChkUser${users.getId()}">
If the state of the checkbox changes then updating the hidden field value. Which can be used in for msubmission.

Related

asp-for does not generate code on Razor Page

I must be missing a configuration setting.
Simple example:
<input asp-for="Login.UserIDMaybe" type="text" class="inputStandard" placeholder="User ID" autofocus>
When the page compiles, the result is that exact same HTML, and when the form is submitted, the UserIDMaybe property of the model is always null.
To test that everything else is cool, I can replace that input HTML with the following, and it works (the Login.UserIDMaybe value is filled with what the user entered into the Input).
<input for="Login.UserIDMaybe" type="text" class="inputStandard" placeholder="User ID" autofocus>
Maybe I have completely misunderstood the usage of asp-for, or maybe I have failed to "turn it on". Thanks.
And yes "#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers" is in the _ViewImports.cshtml file, but maybe that is not enough.
If you are using MVC and Razor Pages, make sure you have a _ViewImports.cshtml in your Pages folder too.

Netlify form submissions are blank

When I submit my Netlify form the server responds with a 200 status and I get the 'thank you' response page. However, when I check the form submission in the Netlify admin, they are all blank. I've inspected my xhr requests and the data shows in the 'params' section of the browser dev tools.
Disclaimer: I work for Netlify.
When our service stores blank submissions, it has not received any fields from the submission which were defined in the html version of the form with the same name parameter in its definition as the submission.
To start off with, it's useful to know that our service requires a plain html version of your form, with a name parameter as well as the netlify or data-netlify=true parameter; this is what prepares your site to accept form submissions at all, so you had that set up right already; if you didn't, you'd get a 404 when POSTing.
Once you have this in a deploy and we parse it correctly, you'll see the form name in your site settings dashboard on the 'Forms' tab. Note that we ALSO pull all the field names we'll save and show to you in notifications or the dashboard from this file and only this file, so make sure you give each form field all a name as well, in that html file.
If you see the form in your dashboard, yet get a blank submission when you are sure data was POSTed, this probably has one of three causes:
Netlify did not correctly process your field names from the html version of your form. The service will only properly handle the fields which we see in that html version at deploy time.
Netlify does matching by field name at submission time, so make sure that what your site sends to us then matches up between with your deployed html copy of the form. This happens automatically for pure html (no JS) forms since you are POSTing from the file which is the canonical "definition" of your form fields; however for javascript forms you need to take care that the names match up. Put another way, you cannot later add new fields dynamically in javascript and send them (Netlify will accept all fields, as you have seen; but will not store them or notify you about ones that were not processed at deploy time!)
One more quirk that could get in the way: having multiple copies of a form with the same name in your deploy. Only one will be processed, so if you happen to have an errant <form name=test netlify></form> in another html file (or even the same one!) - it could be the one that we process rather than the other form also named test. So, make sure that you only send a single html definition of your form. Note that some frameworks like gatsby render your jsx down into html before deploy, meaning that if you have a plain html file form definition in your deploy - it could be processed instead of the copy gatsby built.
This blog post describes a successful form built in a react app: https://www.netlify.com/blog/2017/07/20/how-to-integrate-netlifys-form-handling-in-a-react-app/
I missed the "name" attribute in input field.
Every input in the form must have a "name" attribute. Something like <input name="email" ...> or <textarea name="message" ...> is what you need.
Don't miss the "name" attribute for both parent and child layers
<form name="contact" method="POST" data-netlify="true">
<input type="text" placeholder="name" class="box" name="name">
<input type="email" placeholder="email" class="box" name="email">
<input type="text" placeholder="project" class="box" name="project">
<textarea name="message" id="" cols="30" rows="10" class="box message" placeholder="message"></textarea>
<div class="field">
<div data-netlify-recaptcha="true"></div>
</div>
<button type="submit" class="btn"> send <i class="fas fa-paper-plane"></i> </button>
</form>

How can I pass "type" attribute within <html:text> in struts1

When I try to write something like this: <html:text styleId="Istituto" type="number"> in the struts1 it gives me an error
Attribute type invalid for tag text according to TLD
How can I add "type" attribute to <html:text> tag?
I know this is old, but I'm currently working on a super old application that uses Struts 1 framework, and today I had the same problem. Here's the solution I'm using that works:
<input type="number" name="budgetValue"
value="<bean:write name="applicantForm" property="budgetValue"/>">
Where:
budgetValue - is the Form property; applicantForm - is the Form
Thanks to Milebza for the answer, but for me only this way has worked.
<input type="number" name="budgetValue" value="${applicantForm.budgetValue}" />

Lotus Web issue with browser

I have been using display.none, for the hid-whens for example, all the hidden fields were kept in a section and section was hidden from web by using Display.none.
This is working for Internet Explorer till IE 9, but for IE 10 all the hidden fields are shown.
Can anyone help in this matter. Any alternative or approach.
Without seeing the page it sis very difficult to guess.
Try validating the html through one of the many online html validators as something may not be closed or Notes might have given you an unwanted code addition .
Try adding a background color to the css #wrapper to make sure the css is being called.
Take a copy of the form and start removing all other elements one section at a time to see if something else is causing the issue.
Add {meta http-equiv="X-UA-Compatible" content="IE=10;IE=9; IE=8; IE=7; IE=EDGE" /} as the very top meta tag and see if that fixes it. Replace the curly braces obviously.
All the best in finding the issue.
It sounds like just the section element is getting hidden. Without seeing the code I can't tell why that changes between ie 9 and 10 but ie is famous for having varying behavior between versions.
One alternative that comes to mind: You could wrap the section and the fields in a DIV element using pass thru HTML and set that div's style to display:none. That is pretty standard and should work across browsers.
Update: To give you an idea what I'm talking about, check out this jsfiddle.
HTML:
<form>
<div class="wrapper">
<input type="text" name="Field 1" /><br />
<input type="text" name="Field 2" /><br />
<input type="text" name="Field 3" />
</div>
<span>Some text that won't be hidden.</span>
</form>
CSS:
.wrapper {
#display:none;
}
You can remove the # next to the display:none and see the difference, even in IE 10.
You'll need to look closely at the HTML being rendered by Domino and make sure that in fact all the fields you are trying to hide are surrounded by the DIV that is hidden.

Capybara not finding submit button by name

I have some weirdness occurring while trying to switch from webrat to capybara. The error is this:
And I press "Create floob"
# features/step_definitions/web_steps.rb:27
no button with value or id or text 'Create floob' found (Capybara::ElementNotFound)
The html in my app looks like this:
<fieldset class="buttons">
<ol>
<input id="floob_submit" name="commit" type="submit" value="Create floob" />
</ol>
</fieldset>
I would have thought that capybara would look at the value of the buttons on the page, and reading the documentation this does seem to be the case, but it's not working! If I change the line in my cuke file to And I press "floob_submit" everything works, but I'd rather not change all my features...
Does anyone have any thoughts on why this might be happening and if there's a fix? Thanks friends!
The only thing I can see is that you aren't wrapping your input in an <li></li>. This might be confusing enough for the DOM to cause your problem.

Resources