FLUID ViewHelper form in new window - forms

I would like to add the target attribute to a FLUID form, so that after submitting the form, a new window is created.
This does not work, and produces an error:
<f:form target="_blank" action="..." name="..." id="..." pageUid="..." controller="..."></f:form>
Any ideas on how to make the to open in a new window?
I use TYPO3 6.2beta5

As the f:form ViewHelper inherits from the AbstractTagBasedViewHelper, it shares the same allowed attributes.
The fluid documentation inside the TYPO3 Flow documentation shows you all allowed attributes.
To answer your question, the correct way to use it would be:
<f:form additionalAttributes="{target:'_blank'}">FORMCONTENT</f:form>
Note that the additionalAttributes argument is an array. If you were to add more than 1 custom attribute, you would do it like that:
<f:form additionalAttributes="{target:'_blank', data-validate: 'foo'}">FORMCONTENT</f:form>
EDIT
The AbstractTagBasedViewHelper changed, so the answer as of today for TYPO3 CMS v7 would be: There's an attribute data for that which takes an array of keys and values.
<f:form data="{foo: 'bar', validate: 'baz'}" ....>
FORMCONTENT
</f:form>

Related

How to use f:translate within additionalAttributes of f:form.textfield

I'm trying to insert a translated placeholder within my f:form.textfield
<f:form.textfield name="search[sword]" value="{sword}" class="form-element" additionalAttributes="{placeholder: '<f:translate key="placeholder" />'}"/>
The output works if I replace the placeholder with normal text. I can output my translated placeholder elsewhere as well, but not within the attribut of the f:form.textfield.
I can not spot a syntax error.
Use inline sysntax, for additional attributes like:
<f:form.textfield name="search[sword]" value="{sword}" class="form-element" additionalAttributes="{placeholder: '{f:translate(key:\'placeholder\')}'}"/>
With TYPO3 CMS >= 6.2 you can use placeholder directly as argument for textfields:
<f:form.textfield name="search[sword]" value="{sword}" class="form-element" placeholder="{f:translate(key:'placeholder')}"/>

Access flux fields from another Fluidtypo3 FCE element (flux, fluidcontent, vhs)

I'm trying to access the settings of a Fluidtypo3 FCE element. My FCE is a news article that I want to include in another FCE, which is a slider. The slider only has one field and the configuration is the following:
<flux:field.relation
name="articles"
label="News-Beitrag"
multiple="true"
size="6"
table="tt_content"
condition="AND tt_content.pid = {record.pid} AND CType = 'fluidcontent_content' AND colPos = 1 AND sys_language_uid = {record.sys_language_uid}"
minItems="1"
maxItems="10"
renderMode="default"
/>
This configuration works, I can select all my news FCE's as a relation. The field articles saves the uid's of all referenced FCE's. Now I am trying to use these uid's to receive the content. Right now my code is the following:
<f:section name="Main">
<f:if condition="{articles}">
{v:iterator.explode(content: '{articles}', glue: ",", as: 'articles')}
{v:content.get(contentUids: "{articles}", render: 0) -> v:variable.set(name: 'slides')}
<f:for each="{slides}" as="element">
</f:for>
</f:if>
</f:section>
The <v:content.get> ViewHelper gets the tt_content record as it is recorded in the database. The flux settings are stored in XML-Format in the field pi_flexform. I am trying to access those specific flux settings one by one and not just the whole pi_flexform field in xml format.
I've looked for ViewHelpers that can convert XML to an Array and tried many other things, but nothing worked for me. I am grateful for any ideas how to solve this problem.
<flux:form.data> is the Viewhelper you seek. You can use it like this:
<f:for each="{slides}" as="element">
<flux:form.data table="tt_content" field="pi_flexform" record="{element}" as="flexformData">
<!-- Do stuff with flexformData -->
</flux:form.data>
</f:for>

Is it possible to set by fluid a argument that the typo3 backend uses as input

In the typo3 template I'm using the following line to get the last 5 added items from the backend and this works.
<f:cObject typoscriptObjectPath="lib.lastaddeditmes" />
Only the number of item I want to have it flexible and set in the fluid template. So for example like below where the qty is set to three, is this possible?
<f:cObject typoscriptObjectPath="lib.lastaddeditmes(3)" />
You can't do that in the view, instead you can make a copy of lib.lastaddeditmes in TypoScript and then use it in other place like:
lib.lastaddeditmesOnlyThree < lib.lastaddeditmes
lib.lastaddeditmesOnlyThree.someSetting.items = 3
and in view:
<f:cObject typoscriptObjectPath="lib.lastaddeditmesOnlyThree" />
Remember that TypoScript is just a configuration syntax (not programming language) so it shouldn't give you any huge performance drop.

How to disable automated encoding of special characters in fluid partials (TYPO3)

Should be simple enough. I'm trying to add an input field to a fluid partial in the extension "yag" (yet another gallery).
Input: <f:form.textfield id="live-filter" name="test" />
Output: <input id="live-filter" type="text" name="test" />
Somehow the code get's filtered along the way, but I don't know why.
TYPO3 v. 6.2
YAG v. 3.2.1
Edit: A wild guess would be some output filtering in TYPO3 itself, but where? I didn't set anything by purpose.
You need to traverse the path upwards to check if there is any fluid tag wrapped around it, that does escaping. In general, all tags do escaping.
Also check the code around <f:render partial....
It could also be that the TypoScript code that does calls the fluid template, has a .htmlspecialchars = 1 set.
Since TYPO3 8 there is another pitfall: Custom Viewhelpers do htmlspecialchars on the output unless told otherwise. The solution is:
<?php
namespace Vendor\ArTest\ViewHelpers;
class YourViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper{
/**
* As this ViewHelper renders HTML, the output must not be escaped.
*
* #var bool
*/
protected $escapeOutput = false;
As of TYPO3 ver. 9.5 and up to ver. 10.4 you could also wrap the output in the Fluid template into <f:format.htmlentitiesDecode> Tags like this:
<f:format.htmlentitiesDecode>
<f:form.textfield id="live-filter" name="test" />
</f:format.htmlentitiesDecode>
Further information on this can be found in the TYPO3 View Helper Reference.

Zend Frameword 2: How to set a html link (img) in a legend of the fieldset?

I used zf2 to design a website.
And the form is something like this:
$this->add(array
'options'=>array(
'label'=> 'title1'))
And finally it shows like this:
<form>
<fieldset>
<legend>title1</legend>
<label>****</label>
</fielset>
</form>
Now, I wanna add a link or an image after the title1, for example:
<form>
<fieldset>
<legend>title1<a href=''>link</a></legend>
<label>****</label>
</fielset>
</form>
How can I do this?
You can't. Well, at least not without overwriting the specific ViewHelper (probably formCollection()). In ZF2 all Labels are run through the Zend\View\Helper\EscapeHtml ViewHelper. Therefore using any sort of HTML inside Labels is not supported in any way.
While going by specification it may be allowed to use inline-elements inside the <legend> Element, semantically it looks a little different. The <legend> shall do nothing but to describe the contents of the <fieldset>.
Anyways, opinions aside, as i've mentioned, you'll have to overwrite the ViewHelper and then skip the use of the EscapeHtml ViewHelper, as it's done in this line of the formCollection() Code