I am using JMS\Serializer in my project and I want to ignore one property only if the array in it is empty.
I tried something like :
#JMS\Exclude(if="count('$this->required') === 0")
or
#JMS\Exclude(if="empty('required')")
but got a syntax error.
Can anyone help me on this?
thank.
What you need was implemented recently and it is in release-1.7 so you might as well wait for it. It is called #SkipWhenEmpty
#SkipWhenEmpty This annotation can be defined on a property to
indicate that the property should not be serialized if the result will
be "empty".
This is the bug related it.
You need this one:
#JMS\Exclude(if="!object.required")
Related
I'm using Array.prototype.flatMap, and it's working, but Flow is complaining:
Cannot call `this.state.quantities.flatMap` because property `flatMap` is missing in `Array`.```
Huh??? How do I fix this?
Array.prototype.flatMap was added to Flow in version 0.103.0. You'll need to update to that version or a newer one before you can typecheck flatMap.
I get an error with RKUIManager, or more precisely:
Could not invoke RKUIManager.manageChildren
It appears for example when I'm using firebase with React Native and try to set a reference in the constructor of a component with a prop. For ex:
messagesRef = FBRef.child("Messages").child(this.props.currentMeetingID)
If I change it to the following it works, and yes, I have checked if this.props.currentMeetingID is a legitimate value.
messagesRef = FBRef.child("Messages").child("123456789")
I can't seem to locate the problem nor reproduce it perfectly. I'm just trying to figure out if it's my machine or some kind of bug elsewhere.
Right now I'm just looking for info about what RKUIManager actually is.
If I nullcheck this.props.currentMeetingID I fix it, easy fix but nowhere to be found on the internet so I'll leave it here for anyone passing by. Probably me in a couple of weeks...
When I call this:
buttonrow1.checkedButton = _button1
then I get no errors and nothing happens, I can also not change the property using states, no matter what I do it just remains at the default setting. Any idea how I can change this value?
buttonrow is not a built in type. So please add your definition and tell us what you need to do with:
buttonrow1.checkedButton = _button1
In Smarty, I know you can declare a string:
{$somevar|default:'some string'}
or even an array:
{$somevar|default:array('someval')}
How do you/Is it possible to set an associative array as a default value? as this doesn't seem to work:
{$somevar|default:array('default'=>array('subkey'=>'subval'))}
I just tried:
{$somevar|default:array('key'=>'val')}
It's the '=>' smarty doesn't like
I know its probably not the solution you're looking for, but you can always just use the {php} feature. However, I will try a few things and see if I can work the format out.
Just out of interest, why are you trying to do this in the tpl file and not in the calling PHP script?
Edit
From takeing a read, it doesn't seem like it is possible. However, there is a "set" plugin which allows it, see here (bottom example).
I'm working on a search component for an app I'm working on and I needed to add some filters to it. I've found an example and got the first filter working fine.
Now I'm trying to add a second filter I'm running into problems... In the example I found they use filterFunctions, but I only get an option for filterFunction, why is that?
Here's the example code
productsCollection.filterFunctions =
[
filterByPrice, filterByType,
filterByCondition, filterByVendor
]
And this is what I'm trying
acData.filterFunction = [filterByStatus, filterByDate]
but with this code I get the following error message - 1067: Implicit coercion of a value of type Array to an unrelated type Function.
Why am I getting this error and how would I go about add multiple filters to my Array Collection?
Thanks!
filterFunction must be set to a single function, not an Array or any other datatype. To combine multiple functions create one that combines them, like this:
acData.filterFunction = function(item:Object)
{
return
filterByPrice(item) &&
filterByType(item) &&
filterByCondition(item) &&
filterByVendor(item);
};
If you saw a sample that used filterFunctions plural that accepted an array, post a link. That's not anywhere in the standard Flex framework or in the new 4.0 beta afaik.
It looks like you are going to have to extend an arraycollection to make it work. this link should spell it out for you: http://blog.rotundu.eu/flex/arraycollection-with-multiple-filter-functions/