-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
ObjectSelect with "multiple" #215
Comments
Seems more like a hydrator problem to me. What is the data passed to the hydrator? |
@Ocramius When all selections are removed there won't be a submit of this field. Create post of the complete form:
Update post -> remove all modules (unselect the selection from create)
The thing is that when using "single" there is always a post send, but not with multiple. |
@ThaDafinser I think this is a ZF2 issue that was solved recently. Can you please check? |
I'll try to check if i find it. |
News? |
@Ocramius In my case i dont use the empty_option, so this does not apply. The problem with empty_option is, that it will be an option and i don't won't this on a multi select.... The problem is only about the "mutliple" elements, single elements are fine (because single elements are always submitted). The POST is like written above, empty when nothing is selected. The main problem is for the DoctrineObject to find out if the element is displayed/rendered on the form, when it's rendered and the POST is empty, associations could be removed.... But currently the DoctrineObject known nothing about the form elements .... :-/ Do you maybe got any idea? |
@ThaDafinser there's strategies to disallow removal - and no, the hydrator can't know of the form at all. |
@Ocramius this is my current "workaround" for each collection: When the POST is empty and the collection is not, i just clear it. //EDIT
$data = $request->getPost();
$dataEntry = $data['event']['entry'];
$entry = $event->getEntry();
if (count($entry->getTags()) > 0 && ! isset($dataEntry['tags']) && $form->get('event')->get('entry')->get('tags') !== null) {
$entry->getTags()->clear();
}
$entityManager->flush(); The only way to automate this, would be a dependency to the form -> so the strategy know about which elements are set (and possibly not send). //EDIT know the 3rd if, checks if the elements is around (if not, don't remove all relations...) |
The global shard settings are configured through the normal connection settings. Refs doctrine#215
@bakura10 is this supposed to be closed by bakura10/zf2@469ddd8 ? |
Re-opening. @ThaDafinser I'm poking you again for updates just to see if @bakura10's PR actually changed anything. |
@Ocramius , I'm not sure to understand. as far as I remember I'm not the author of the commit that was merged (well, I'm actually sure, I've never used multiple selects). I don't remember exactly how Select mapped to Doctrine hydrator, but as far as I remember, you're right, that's a hydrator issue, and the collection must be cleared. I suppose the hydrator calls "removeElements" with the elements. So if the given array is empty, it should result in a clear in entity land. But once again, it's been a while I didn't use that :/. |
Hi, same behaviour here with ObjectMultiCheckbox and no element selected. @bakura10 I think as well it's rather a problem of the hydrator. |
Works for me. Just type:
in "Options" / "options" |
Don't know why this is closed when its still an issue |
@PoetikDragon the author closed it. |
For me it's not an issue anymore / i don't need it anymore. If you still need it, just open a new issue and refer to this one. |
Hello,
the ObjectSelect works generally well with "multiple" select. (but i don't know if it's tested already)
You can add or remove multiple relations very well.
But when you want to unselect all selected in the form, where won't be a submit of the select field.
With no POST doctrine don't remove the relations.
Test case: Create a entry with one or more relation. Try to edit this entry and remove there all relations -> it won't remove the relations.
The text was updated successfully, but these errors were encountered: