-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prepareImportValue is wrong #76
Comments
In the if($mode === $modes->getValue) {
if ($this->get('allow_multiple_selection') === 'no') {
$data = array(implode('', $data));
}
return implode($data);
} I do not understand the implode -> array -> implode thing... I am not saying that your patch is not valid tho. I just do not fully understand what's going on... |
Maybe we need to change two lines ? 😄 |
Yeah, that's what I've changed from. Sorry, I changed two lines. if ($mode === $modes->getValue) {
if ($this->get('allow_multiple_selection') === 'no') {
return implode('', $data); // <-- I changed this line
}
return $data; // <-- I have changed this little line too
} |
Ok thanks, I just wanted to make sure I was testing the right stuff. |
But without testing, I does look better then before. 😄 |
As an extension author, would you expect return array(
'getValue' => ImportableField::STRING_VALUE,
'getPostdata' => ImportableField::ARRAY_VALUE
); The As for this block, it's just personal preference. I usually like to return as early as possible so I'm not really sure why I did that way =\ if($mode === $modes->getValue) {
if ($this->get('allow_multiple_selection') === 'no') {
$data = array(implode('', $data));
}
return implode($data);
} |
Ah, but the SBL is a special case with regard to values. It can be wither a single string, or an array of strings (as accepted by the field post data functions). IMO, this function should provide values as accepted by the field, which is therefore multiple values or a single value. |
Otherwise, how can you ever process an array of values? |
I can understand your point about the XML Importer, but what would we do to solve this from that perspective? Definitely don't want to go down the road of specifically naming array based fields, as that only causes headaches in compatibility issues for fields. |
Fortunately, a quick projects search shows that most fields that implements the Fields that support a single value, or multiple values already have this support in the |
Right, I'll have a look at breaking a local build then ;) |
I've been pulling my hair out for an entire day as to why I can't import multiple values into a Select Box Link via the XML Importer.
I remember having the discussion with @brendo on the forum (http://www.getsymphony.com/discuss/thread/45612/) as to how to do it, and yet it still just wouldn't work. Single values always worked, but never multiple values.
Take this
Using an expression of
./items/item
should allow a developer to add these values to amultiple
Select Box Link, yet it fails every time. It always concatenates the values into a string.I never even thought that it was the SBL itself that was doing the dirty here, as it's not changed with this regard for sooo long, but I was wrong.
No matter what you pass the SBL's
prepareImportValue
function, using thegetValue
style, it always returns a flat string, even though the field itself is more than capable of ingesting anarray
.I've hacked a change to it as follows.
Instead of (as it currently is)
implode($data)
being where I have changed it (as commented), I let it return an array!Now the XML Importer finally works as expected. That's three years of me having to find hacks and convoluted methods of associating import data. One line.
@brendo can you clarify this change and let me know if it will break anything else? @nitriques could you test it too for me before I PR this change, I want to make sure that I don't break anything.
Also, this will need replicating into the Association Field if all is good.
The text was updated successfully, but these errors were encountered: