get values of multiple checkboxes in extbase/fluid TYPO3 - typo3

How to get values of multiple checkboxes checked in frontend template with fluid and use these values in action extbase?

Declare the argument in your controller action and give it a type array or an array-compatible type which can be constructed by the PropertyMapper.
Name all fields the same as this argument.
Post the data and use the argument in the controller action.
This is the correct way of receiving an array as value of a controller argument. Accessing it directly from the request is not recommended, unless you also declared the argument on the controller action. Not doing so will bypass important argument processing.

save them in a form and retrieve the POST data trough:
$this->request->getArgument('variable')

Related

Specification builder doesn't recognize transient properties

I'm trying to implement specification in one of my use cases.
As u can see in the function dateValueBetween, I'm trying to get from the root the transient property valueDate. But when calling this service with real data it give the error downside.
My original problem was how to call the builder.between method but the value I have is a String value and need to be parsed.
but it seems that the first argument need to be a property of the table and not a function.
How can I achieve my goal?

Passing complex object as parameter to sub-stack

I want to pass the output of a custom resource, which is an array of objects, as parameter to a sub-stack. An example of what I want to pass as parameter to the child stack is :
[
{"Role":"Role1","IdentifierType":"Prefix","Identifiers":"Bucket1"}
{"Role":"Role2","IdentifierType":"Prefix","Identifiers":"Bucket2"}
]
How do I pass this to the sub-stack? I tried declaring the parameter in the child stack as String, and later as CommaDelimitedList. Both the times, the stack gave an error: "Value of property Parameters must be an object with String (or simple type) properties"
As I know until now, there is not way to pass complex objects as a result of of stack execution. Like the message say, the outputs need to be string or single types (integer and boolean in case of cloudformation).
Without more information is hard to help you with alternatives, but let's assume that your Custom Resource is based on lambda. And let's assume that you have control about the code of your Custom Resource. If this is the case you can:
Send the resource identification of your custom resource as a parameter for your nested stack;
Inside nested stack, invoke the lambda function again with the resourceId as a parameter;
Change the lambda code to check for a new parameter for the resourceId (inside the ResourceParameters, not inside the Common Resource Id sent by CloudFormation).
If the parameter is not empty (or not a defined value passed on the first invocation) respond with the old values (you must have a way to keep this values in some place or check then in runtime.);
Change the lambda code to do not take action in the update/deletion is case of invocation by the nested stack (with the resourceId parameter).
Again, is hard to think in alternatives without more info about your specific problem. But use this response as a food for thought.

Passing selector in data-sly-resource in sightly

I am not able to pass the selector parameter in the data-sly-resource (when parameter is coming through some external object like java or through some list object). It does not work even though if i initialize a variable using "use" statement and then pass in data-sly-resource statement. However this is working fine when i am passing the hard coded values.
For example , below code works because it has hard coded value 'test value'
<sly data-sly-test="${item.tileReference}"
data-sly-resource.="${item.tileReference # wcmmode='disabled', selectors='test value',
resourceType='abc/tiles/generic-tile'}">
</sly>
However, below code doesn't pass the parameter value because it is coming through some object. here, 'tile.tileCount' holds the value which i have verified by printing in the html.
<sly data-sly-test="${item.tileReference}"
data-sly-resource.="${item.tileReference # wcmmode='disabled', selectors=tile.tileCount,
resourceType='abc/tiles/generic-tile'}">
</sly>
Turns out that Sightly accepts only String as selectors and passing an int value ignores the selector.
Looks like tileCount is an integer, try using a String value instead to fix the issue (the getter method of tileCount can be made to return a String instead of an int).

Fluid: Directly access value of array returned by view helper

I've got custom fluid ViewHelper that returns an array, and I'd like to access a value of this array directly in one command.
Currently I'm using two commands:
{vendor:helper() -> v:variable.set(name: 'data')}
Value of foo: {data.foo}
Is there a way to do this in a single command? v:variable.get does not seem suited for this task.
As #Jpsy said, there is the VHS Variable / GetViewHelper.
But the usage should be {v:variable.get(name: '{vendor:helper()}.foo')}.
If you need the returned array of your viewhelper multiple times in your template, it's better to use it the way you already did. Because otherwise you would call the PHP method behind the viewhelper to build and return the array each time you want to access an index of an already previously built array again.
v:variable.get of VHS viewhelpers does exactly what you want:
{v:variable.get(name: 'data.{foo}')}
This returns the item with index {foo} from array data.
You write that you're using a custom ViewHelper.
Can you modify it?
Inside the ViewHelper you can easy assign a Variable with:
$this->templateVariableContainer->add('variable', 'content');
It depends also on what you're really trying to reach. If you want to cicle the array, you should create a different viewhelper
If you want to create the array, and then access all the data in different position, you're looking for the f:alias fluid helper
Int he last situation, where you look a direct access of a property immediately after the helper call and no more about it, you have to change your viewhelper, with an optional value. If the helper recive the value, you return the element, otherwise it returns the entire array

What Zend View Partial setObjectKey do?

i am reading zend framework docs on zend view partials
If your model is an object, you may
want to have it passed as an object to
the partial script, instead of
serializing it to an array of
variables. You can do this by setting
the 'objectKey' property of the
appropriate helper:
// Tell partial to pass objects as 'model' variable
$view->partial()->setObjectKey('model');
but what does this do. when do i use it and how.
I'm not 100% positive on this, but from what I can tell by looking at the source and documentation is that standard behavior for rendering a partial is that values are passed into it in the form of an associative array. This allows the values to be bound to variables using array keys.
echo $this->partial('partial.phtml', array ('person' => 'joe');
// in my partial..
<h1><?php echo $this->person; ?></h1> //<h1>Joe</h1>
If you pass an object as the third parameter, (ie, partial('partial.phtml', $myobject);), Zend_View_Partial will automatically serialize that object in an associative array, either by a custom implementation of toArray() or it will just grab the public properties via get_object_vars().
However, if you want to pass the whole object, as an object, you need to set the array key that gets transformed into a variable for the partial to reference.
$this->partial()->setObjectKey('myobject');
echo $this->partial('partial.phtml', $myobject);
What benefits this approach has over partial('partial.phtml', array( 'myobject' => $myobject), I'm not sure. Or I could be interpreting the documentation wrong.
Key as in array(key => value)?