[Flow] Usage of Multiselect

Mark Kuiphuis typo3 at markyourweb.com
Fri Sep 27 01:22:45 CEST 2013


On 10/09/13 6:05 PM, Christian Loock wrote:
> Hello,
>
> I have a problem with a Multiselect I am using to select roles.
>
> Here is the form snippet I use:
>
>
> <f:form.select multiple="true" name="roles" options="{availableRoles}"/>
>
> {availableRoles} is a query result from the roleRepository.
>
> I also added a Validator to my action that receives the form:
>
> @Flow\Validate(argumentName="roles", type="NotEmpty")
>
> However, when I submit the form, without having a role selected, I get
> the following error:
>
> *#1297759968: Exception while property mapping for target type "array",
> at property path "": No converter found which can be used to convert
> from "string" to "array".* (More information
> <http://typo3.org/go/exception/1297759968>)
>
> I tried tricking this error by adding a hidden field in front of my
> multiselect, to simulate a selection with an empty string. However, the
> Validator wont work here anymore.
>
> I couldnt find anything about this googling. But I am sure, there must
> be a way to get this very basic usage of a multiselect to work and am
> probably just missing something.
>
> Greetings,
>
> Christian

I am not sure, but what if you pass in an array instead of a single 
value, like this:

<f:form.select multiple="true" name="roles[]" options="{availableRoles}"/>

As you are not using property="roles", you might want/need to add the 
property as an parameter in your action as well.

/**
  * @var array $roles
  */
public function ....Action(array $roles) {
	// Do something here....
}

Cheers, Mark


More information about the Flow mailing list