Modifying TYPO3 form.checkbox hiddenfield - typo3

When the following code is added to a partial HTML class in TYPO3.
<f:form.checkbox id="myCheckBox" property="myCheckBox" value="Y" multiple="no" />
When the form is loaded within a TYPO3 extension the following code is generated for the checkbox
<input type="hidden" name="form[newForm][myCheckBox]" value="" />
<input id="myCheckBox" type="checkbox" name="form[newForm][myCheckBox]" value="Yes" />
Is there a way of adding the parameter ID to the auto generated hidden field so we have:
<input type="hidden" id="myCheckBoxHidden" name="form[newForm][myCheckBox]" value="" />
<input id="myCheckBox" type="checkbox" name="form[newForm][myCheckBox]" value="Yes" />
Using TYPO3 7.6.13

I think you could extend the CheckboxViewHelper and add the id attribute as you needed, and then use your new VH instead.

Related

How to fix the faulty mailform output since TYPO3 6.2.47 ELTS?

Since the last update to TYPO3 6.2.47 ELTS forms (the old core forms; without use of sysext "form") are no longer rendered normally ...
<input type="text" name="name" id="mailformname" size="30" value="" />
... but the input fields seem to be sent through an HTML encoder. It now looks like this in the source code:
<input type="text" name="name" id="mailformname" size="30" value="" />
How can this be fixed?
I couldn't find anything related to this in the changelog.
There's a new parseFunc, which is responsible for the issue
tt_content.mailform.20.stdWrap.parseFunc =< lib.parseFunc
You can overwrite this as follows
tt_content.mailform.20.stdWrap.parseFunc >

Front end entry form with Craft CMS

I am trying to create a form with Craft that allows users to rate entries in a specific section. The section that tracks the ratings has three fields: the ratings drop-down field, a user field, and an entry field. Here is my form right now:
<form method="post" accept-charset="UTF-8">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="entries/saveEntry">
<input type="hidden" name="redirect" value="viewentry/{slug}">
<input type="hidden" name="sectionId" value="userRatings">
<input type="hidden" name="enabled" value="1">
<input type="text" id="user" name="ratings" value="{{currentUser}}" style="display:none;" readonly>
<input type="text" id="restaurant" name="restaurant" value="{{entry.id}}" style="display:none;" readonly>
<label for="ratings">Rate This Restaurant</label>
<select id="ratings" name="ratings" required>
{% for option in entry.ratings.options %}
<option value="{{ option.value }}">{{option.label}}</option>
{% endfor %}
</select>
<input class="button" type="submit" value="Rate">
I have two text boxes that are recording the current user and the Entry ID of the entry I am trying to rate (we are on the _entry.html for this entry). Before I added the "display:none" they were both showing the correct information. Then I am pulling the options for the ratings field that I set in craft and setting them as the values for the drop down here (which is working).
When I try to submit I get a craft error: "Internal Server Error Trying to get property of non-object." Any help or suggestions would be greatly appreciated!
You're missing the 'title' field ..
<input type="hidden" name="title" value="Free Registration Title">
It's a requirement

How can I conditionally require form inputs with AngularJS?

Suppose we're building an address book application (contrived example) with AngularJS.
We have a form for contacts that has inputs for email and phone number, and we want to require one or the other, but not both: We only want the email input to be required if the phone input is empty or invalid, and vice versa.
Angular has a required directive, but it's not clear from the documentation how to use it in this case. So how can we conditionally require a form field? Write a custom directive?
There's no need to write a custom directive. Angular's documentation is good but not complete. In fact, there is a directive called ngRequired, that takes an Angular expression.
<input type='email'
name='email'
ng-model='contact.email'
placeholder='your#email.com'
ng-required='!contact.phone' />
<input type='text'
ng-model='contact.phone'
placeholder='(xxx) xxx-xxxx'
ng-required='!contact.email' />
Here's a more complete example: http://jsfiddle.net/uptnx/1/
if you want put a input required if other is written:
<input type='text'
name='name'
ng-model='person.name'/>
<input type='text'
ng-model='person.lastname'
ng-required='person.name' />
Regards.
For Angular2
<input type='email'
[(ngModel)]='contact.email'
[required]='!contact.phone' >
Simple you can use angular validation like :
<input type='text'
name='name'
ng-model='person.name'
ng-required='!person.lastname'/>
<input type='text'
name='lastname'
ng-model='person.lastname'
ng-required='!person.name' />
You can now fill the value in only one text field. Either you can fill name or lastname. In this way you can use conditional required fill in AngularJs.
In AngularJS (version 1.x), there is a build-in directive ngRequired
<input type='email'
name='email'
ng-model='user.email'
placeholder='your#email.com'
ng-required='!user.phone' />
<input type='text'
ng-model='user.phone'
placeholder='(xxx) xxx-xxxx'
ng-required='!user.email' />
In Angular2 or above
<input type='email'
name='email'
[(ngModel)]='user.email'
placeholder='your#email.com'
[required]='!user.phone' />
<input type='text'
[(ngModel)]='user.phone'
placeholder='(xxx) xxx-xxxx'
[required]='!user.email' />
For Angular 2
<input [(ngModel)]='email' [required]='!phone' />
<input [(ngModel)]='phone' [required]='!email' />

Submitting array/list/seq via POST in play 1.2.4 with scala 0.9.1

I've only been able to find examples in java, and they all seem to suggest that what I am doing should "just work". I have a form like the following (either with the name as "id" or "id[]", both give the same results). I have tried declaring my edit method as taking List[Int] or Seq[Int], but in both cases id ends up being NULL. If I dump params, I can see that body does in fact contain the correct query string, and if I just do a get("id") it comes back as an int containing the first value (1). How can I get some sort of ordered container (don't care if it is a list or seq or whatever) submitted through a form?
<form method="post" action="">
<input type="hidden" name="id" value="1" />
<input type="hidden" name="id" value="2" />
<input type="hidden" name="id" value="3" />
<input type="hidden" name="id" value="4" />
<input type="text" name="name" />
<input type="submit" />
</form>
def edit(id: List[Int]) = {...}
Play doesn't handle scala collection types from forms, only java collections. Leaving the form as-is but changing the method to:
def edit(id: java.util.List[Int]) = {...}
Solves the problem. Then you can convert your java list into a scala list and use it normally.

Strange JSP behavior while rendering a form in a forEach loop

i found a strange behavior in my JSP site and hope somebody have a good advice for me:
JSP-Code:
<c:forEach items="${info.moneyList}" var="mmRoles" varStatus="uStatus" >
....
<div class="paperback" id="delete_${uStatus.index}">
<form id="deleteMoneyMarketSpread_${uStatus.index}"
action="deleteMoneyMarketSpread" method="post">
<input type="hidden" name="currency"
value="${mmRoles.currency}" />
<input type="hidden" name="loan"
value="${mmRoles.loan}" />
<input type="hidden" name="lcfspread"
value="${mmRoles.lcfspread}" />
</form>
</div>
....
</c:forEach>
I generate a form element with hidden input fields in a forEach loop. The interesting point is that (only) in the first iteration no form element will be created. When i check the HTML code with Firebug i only find the hidden input fields, but no surrounding form tag.
HTML code:
<!-- first iteration -->
<div id="delete_0" class="paperback">
<input type="hidden" value="EUR" name="currency">
<input type="hidden" value="true" name="loan">
<input type="hidden" value="123.0" name="lcfspread">
</div>
...
<!-- second iteration -->
<div id="delete_1" class="paperback">
<form id="deleteMoneyMarketSpread_1" method="post" action="deleteMoneyMarketSpread">
<input type="hidden" value="FGH" name="currency">
<input type="hidden" value="true" name="loan">
<input type="hidden" value="1.0" name="lcfspread">
</form>
</div>
Have anyone an idea why this happens?
Regards
Sascha
I still don't found a solution or a reason for this so i used a workaround an create my Form on demand with javaScript when clicking the icon. Not the best way but it works.