TYPO3 Femanager Passwort additionalAttributes - typo3

I want to extend the additionalAttributes with a second Attribute. In the original Partials it looks like this:
<f:form.password
id="femanager_field_password_repeat"
name="password_repeat"
class="input-block-level"
value=""
additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'password_repeat')}" />
I try this:
additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'password'),placeholder: '{password_repeat}'}" />
With several Verions of Escaping the femanager:Validation..... Got this Error:
The argument "additionalAttributes" was registered with type "array",
but is of type "string" in view helper
"TYPO3\CMS\Fluid\ViewHelpers\Form\PasswordViewHelper“
Any Ideas?

I think
Validation.FormValidationData()
is a viewhelper that returns a whole array which is expected for the attribute "additionalAttributes".
Because of that it's difficult to extend the array at this place.
But as far as I know the femanager-viewhelper itself offers the possibility to extend the final array, all to do is to give your array as a further argument which is called 'additionalAttributes' as well.
A short example:
<f:form.password
property="password"
additionalAttributes="{
femanager:Validation.FormValidationData(settings:settings,
fieldName:'password',
additionalAttributes:'{required:\'required\',pattern:\'.{8,}\'}')}"
}" />
Notice the array of 2 values (required and pattern).
I also recommend to have a look at the viewhelper on github:
https://github.com/TYPO3-extensions/femanager/blob/master/Classes/ViewHelpers/Validation/FormValidationDataViewHelper.php

Related

TYPO3 Fluid dynamic key in arguments

I would like to render a partial with dynamic keys for the arguments.
In the partial:
<f:link.action action="{action}" controller="{controller}"
arguments="{'{argument1name}': argument1, '{argument2name}': argument2}">
{bla}
</f:link.action>
So can argument1name and argument2name be written dynamicly in Fluid? What is the syntax, above is obviously wrong. Even better would be an array with an unknown number of arguments.
I came up with a solution for my problem. In the Fluid Template..
<f:variable name="modalArguments" value="{organization: organization, contactperson: contactperson}"/>
<f:render partial="Components/ActionModal" arguments="{modalTitle: 'Bla', modalBody: 'Are you sure {contactperson.name} bla?', action: 'delete', controller: 'Contactperson', modalArguments: modalArguments}"/>
In the partial something like
<f:link.action action="{action}" controller="{controller}" arguments="{modalArguments}" class="btn btn-primary">bla</f:link.action>
So it's possible to throw the arguments array in a variable.
As in fluid the key for arrays never is wrapped in ' your syntax obviously is wrong.
If a value is wrapped in ' it is constant text, otherwise it is interpreted as variable. So keys are handled in another ways than values.

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')}"/>

TYPO3 Ext. tx_news and absolute links for RSS View

i use the tx_news Extension and i need a absolute url to a single news.
The <n:link [...] /> build a correct link to an single news, but it's not a absolute link.
This don't working:
<n:link newsItem="{newsItem}" settings="{settings}" uriOnly="1" absloute="1" />
And with <f:uri.page absolute="1" /> i can't link to a single newsitem.
But i don't find any other way to build me a absolute link to a single news.
Maybe have someone a little resolution for this problem?
I need this for the RSS-Page for link to newsitems.
As stated in reference document this viewhelper gets optional configuration param which allows to pass an array of typolink settings.
<n:link newsItem="{newsItem}" settings="{settings}" uriOnly="1" configuration="{forceAbsoluteUrl:1}"/>
Use the additional configuration parameter of the n:link viewhelper. It expects an array of parameters as argument that are passed on to the typolink generation.
Important:
Make sure that you wrap more complex values in single quotes or you will end up getting errors. See the quoted value of additionalParams in this example:
<n:link newsItem="{newsItem}" settings="{settings}" configuration="{addQueryString:1, additionalParams:'&tx_news_pi1[#widget_0][currentPage]=3'}" title="{newsItem.title}">
...
</n:link>

FLUID ViewHelper form in new window

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>

Why can't I pass a form field of type file to a CFFUNCTION using structure syntax?

I'm trying to pass a form field of type "file" to a CFFUNCTION. The argument type is "any". Here is the syntax I am trying to use (pseudocode):
<cfloop from="1" to="5" index="i">
<cfset fieldname = "attachment" & i />
<cfinvoke component="myComponent" method="attachFile">
<cfinvokeargument name="attachment" value="#FORM[fieldname]#" />
</cfinvoke>
</cfloop>
The loop is being done because there are five form fields named "attachment1", "attachment2", et al.
This throws an exception in the function:
coldfusion.tagext.io.FileTag$FormFileNotFoundException: The form field C:\ColdFusion8\...\neotmp25080.tmp did not contain a file.
However, this syntax DOES work:
<cfloop from="1" to="5" index="i">
<cfinvoke component="myComponent" method="attachFile">
<cfinvokeargument name="attachment" value="FORM.attachment#i#" />
</cfinvoke>
</cfloop>
I don't like writing code like that in the second example. It just seems like bad practice to me.
So, can anyone tell me how to use structure syntax to properly pass a file type form field to a CFFUNCTION??
In your first codesnippet the value #FORM[fieldname]# evaluates to the name of the file uploaded. So you are sending the filename to your function instead of the name of the field containing the filename.
If you want to stick with the structure notation you might use
<cfinvokeargument name="attachment" value="FORM['#fieldname#']" />
or
<cfinvokeargument name="attachment" value="FORM.#fieldname#" />
instead. I also don't think that there is anything wrong with your (working) second code example.
Edit:
It seems as if <cffile> can not evaluate the filefield if you pass the field using the struct notation, due to some auto evaluation magic of the parameter. After some further investigations I found out that passing only the name of the formfield without the form prefix would also work.
<cfinvokeargument name="attachment" value="#fieldname#" />
The filefield parameter is documented as string, containing the name of the formfield without prefix. My last approach seems more "right" to me. It would even hide the implementation a little bit more. I'm also not so much about composing scope/struct var/keys outside of a component or function and then passing it into the function. This should better be done in the function itself.