blade one hmtl label has not correct value for name element - laravel-blade

I got the folow code:
#foreach($projects as $project)
<label> <input type="checkbox" id="cyhecki2" name= {{$project["bennenungProjekt"]}}> {{$project["bennenungProjekt"]}} </label>
#endforeach
Some "project" has Strings like
some stuff, more stuff
in the "bennenungProjekt" field. With evry String which has a "," in i get wierd labels, like:
<label> <input type="checkbox" id="cyhecki2" name= "IT-techniker," Aufbau Netzwerkinfrastruktur und Support ></label>
The string in this case is " IT-techniker, Aufbau Netzwerkinfrastruktur und Support "
When i now send this as a post Request i only get "IT-techniker,"

Related

angularJS change form input border color on error

This is my first time using bootstrap and angularJS and I have created a login form . If my username does not have the correct length I display an error under the input . However I also want to change the input border color to red if I have an error displayed and I do not know how to do it . If I can do this for a single input I can use it everywhere
My code for a username input :
<form name= "logForm">
<div class="form-group">
<label for="username">Username:</label>
<input type="username" class="form-control" id="uname" placeholder="Enter username" name="uname"
ng-minlength= "10" ng-maxlength = "15" ng-model = "uname" required/>
<span style= "color: #4CAF50" ng-show = "logForm.uname.$valid">Valid</span>
<span style= "color:red" ng-show= "logForm.uname.$touched && logForm.uname.$error.minlength">
Min length is 10
</span>
<span style= "color:red" ng-show= "logForm.uname.$touched && logForm.uname.$error.maxlength">
Max length is 15
</span>
</div>
</form>
So I need to find a way that whenever the error shows up my input border is red and when I have valid input the border must be green .
This can be done using ng-class or ng-style:
solution using ng-style:
<input type="username"
class="form-control"
ng-style="!(!(uname.length < 10) && !(uname.length > 15)) && {"border" : "1px solid red"} "
id="uname"
placeholder="Enter username"
name="uname"
ng-minlength="10"
ng-maxlength="15"
ng-model="uname"
required
/>
You can add class to element using ng-class. More information about this directive is available under documentation: https://docs.angularjs.org/api/ng/directive/ngClass
In your case you want to add some class to form when error is visible. All you have to do is add something like ng-class="{ 'is-invalid': logForm.uname.$touched && logForm.uname.$error.minlength }" into your input. (Please note that class is-invalid is official bootstrap input error class, but can be vary in different versions: https://getbootstrap.com/docs/4.0/components/forms)
<input type="username"
ng-class="{ 'is-invalid': logForm.uname.$touched && logForm.uname.$error.minlength }"
class="form-control"
id="uname"
placeholder="Enter username"
name="uname"
ng-minlength="10"
ng-maxlength="15"
ng-model="uname"
required
/>
If you just want to add some style instead of class, you can use ng-style directive:
https://docs.angularjs.org/api/ng/directive/ngStyle

How to pass variable from hidden input box to another page

I am trying to get a value from a hidden input text box to another page, but it doesn't work. How to pass variable from hidden input box to another page?
Page1.asp
<input type="hidden" name="FormID" value="<% objRS("Form_id")%>
...
<input type="hidden" name="FormID" value="<%= nFormID %>">
<input type="button" value="Open Page2" onclick=openwin();"/>
Page2.asp
<%
iFormID = Request.Form("FormID")
sSQL = "select * from Form where Form_id = " & iFormID
When I click on the Button Open Page2, it doesn't get the value of FormID.
How do I fix it to get the FormID from Page1.asp?
Updated: when I tried to add a button with this JS, it won't get the variable from Page1.asp
I added this on page1.asp:
function openwin()
{window.open("Page2.asp","mywindow","width=500,height=400"):}
<input type="hidden" name="FormID" value="<%= nFormID %>">
<input type="button" value="Open Page2" onclick=openwin();"/>
Thanks.
Since it seems like you're trying to open up a pop up window, I've added a second answer, as you are not actually POSTing any data. if you want to use a pop up, the easiest way is to put the data in the query string, like so:
function openwin()
{window.open("Page2.asp?formID=" + document.frmReport.FormID.value, "mywindow","width=500,height=400"):}
now, i notice you're using a loop to generate the formIDs and using the same NAME for each field. so you'll need to loop through the set of fields, grab each ones value, and send it along as one string in the query string:
function openwin() {
var ids = '';
for( var index = 0; index < document.frmReport.FormID.length; index++ ) {
if( ids == '' )
ids += document.frmReport.FormID[ index ].value;
else
ids += ',' + document.frmReport.FormID[ index ].value;
}
window.open("Page2.asp?FormIDs=" + ids,"mywindow","width=500,height=400");
}
and on Page2.asp, you would do:
iFormIDs = Request.QueryString("FormIDs")
sSQL = "select * from Form where Form_id in ( " & iFormIDs & " ) "
You'll notice that I changed the sql to use the IN clause, that way you can get ALL records for a given set of formIDs, even if it's just one. This obviously doesn't take into account any security precautions to prevent sql injection, but this should get you started.
first, make sure your elements are in a form block with a METHOD of POST
second, your element
<input type="hidden" name="FormID" value="<% objRS("Form_id")%>
needs to be
<input type="hidden" name="FormID" value="<%= objRS("Form_id")%>" />
<%= is shorthand for Response.Write
so page1 would look like:
<form name="myForm" method="post" action="page2.asp">
<input type="hidden" name="FormID" value="<%= objRS("Form_id")%>" />
...
<input type="hidden" name="FormID" value="<%= nFormID %>">
<input type="submit" value="Open Page2" />
</form>

Symfony FormBuilder create multidimensional field name

It is possible to use the basic types of field to create a multidimensional array name?
For example:
<input type="text" name="my_type[translations][name][de]">
<input type="text" name="my_type[translations][name][fr]">
You can use ColectionType. But then you will probably need to change something about how you're using input names like here name="my_type[translations][name][fr]", maybe name="my_type[translations][nameFr]". Using it, your inputs will look like
<input type="text" name="my_type[translations][0][nameDe]">
<input type="text" name="my_type[translations][0][nameFr]">
<input type="text" name="my_type[translations][1][nameDe]">
<input type="text" name="my_type[translations][1][nameFr]">
Here I also presume that you have Translation entity which would have nameDe and nameFr properties.

Why some fields will not show a red boarder when they have model erros

I am working on an asp.net mvc 5 web application. And I have the following inside my edit/create view , to show two fields named ILIOP & Comment:
<div>
<span class="f"> #Html.DisplayNameFor(model=>model.Server.ILOIP)</span>
#Html.EditorFor(model =>model.Server.ILOIP)
#Html.ValidationMessageFor(model =>model.Server.ILOIP)
</div>
<div>
<span class="f">#Html.DisplayNameFor(model=>model.Server.Comment)</span>
#Html.TextAreaFor(model=>model.Server.Comment,new { #class = "textArea"})
#Html.ValidationMessageFor(model =>model.Server.Comment)
</div>
Now on my Post Edit action method I am checking for concurrency conflicts errors and display an error message beside the related fields:
if (databaseValues.ILOIP != clientValues.ILOIP)
ModelState.AddModelError("Server.ILOIP", "Current value: " + databaseValues.ILOIP);
if (databaseValues.Comment != clientValues.Comment)
ModelState.AddModelError("Server.Comment", " Current Value: " + databaseValues.Comment);
Now if there are error on those two fields (ILIOP & Comment) , then the comment field will get a red boarder around it, while the ILIOP will not , as follow:-
now here is the markup when the view is first rendered for the 2 fields (without errors):
<input class="text-box single-line" data-val="true"
data-val-length="The field ILOIP must be a string with a maximum length of 20."
data-val-length-max="20" id="Server_ILOIP" name="Server.ILOIP"
type="text" value="4" />
<span class="field-validation-valid" data-valmsg-for="Server.ILOIP" data-valmsg-replace="true"></span>
<textarea class="textArea" cols="20" data-val="true"
data-val-length="The field Comment must be a string with a maximum length of 256."
data-val-length-max="256" id="Server_Comment"
name="Server.Comment" rows="2">
</textarea>
and here is the markup when errors are displayed for the two fields :-
<input class="input-validation-error text-box single-line" data-val="true"
data-val-length="The field ILOIP must be a string with a maximum length of 20."
data-val-length-max="20" id="Server_ILOIP" name="Server.ILOIP"
type="text" value="4" />
<span class="field-validation-error" data-valmsg-for="Server.ILOIP"
data-valmsg-replace="true">Current value: 3</span>
<textarea class="input-validation-error textArea" cols="20" data-val="true"
data-val-length="The field Comment must be a string with a maximum length of 256."
data-val-length-max="256" id="Server_Comment"
name="Server.Comment" rows="2">
</textarea>
<span class="field-validation-error" data-valmsg-for="Server.Comment" data-valmsg-replace="true"> Current Value: 3</span>
So can anyone advice what is the reason that the ILIOP field does not show a red boarder around it when it has an error associated with it, while the comment field will show a red border ?
I suspect that your CSS for the page is defined in such a way that the textarea element is getting the red styling when both class input-validation-error and class textArea are on the element.
As an initial test of my hypothesis, see what happens if you change
#Html.EditorFor(model =>model.Server.ILOIP)
to
#Html.EditorFor(model =>model.Server.ILOIP, new { #class = "textArea"})
and retry your test case with this change. You may have to rebuild your source code and clear your browser's cache after making this change.

Mac Address Input Box

I'm creating an input box that will only allow 17 characters and is formatted to display as a mac address.
I've added the first 11 characters, the rest the ( last 4 digits of mac) will be added by the user. Is there any way to stop them deleting the initial characters I've preset ?
<script>
function macAdd(val){
if (/[^\w-]|_/.test(val))
{alert("invalid form only alpanumeric and -")
return val}
val=val.replace(/[^\w-]|_/g,'')
val=val.replace(/(\w{2})([^-])/g,'$1'+'-'+'$2')
val=val.replace(/-$/,'')
return val
}
</script>
<input type="text" onkeypress="this.value=macAdd(this.value)" size="30" value="00-00-00-00" maxlength="17"> </p>
Thanks
This seems to achieve what I'm looking to do.
<form>
<input type="text" style="width:130px;" value="00-00-00-00-" readonly><input type="text" style="margin-left : -50px;width:50px;" maxlength="5" onkeypress="this.value=macAdd(this.value)">
</form>

Resources