Skip to content
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

Fix for multiple option #18

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

gonzalocelina
Copy link

When multiple child is set to null (line 30) and on line 62 is called child.id
That comprobation throws an error. I don't fully understand why it calls for child.id because after I quit this if() the field started working and it does everything that it should do (adds the

    , saves on the DB, list the existing ones if the Entity have them, etc.)
    PS: Sorry about my bad english I'm a spanish speaker

When multiple child is set to null (line 30) and on line 62 is called child.id
That comprobation throws an error. I don't fully understand why it calls for child.id because after I quit this if() the field started working and it does everything that it should do (adds the <ul>, saves on the DB, list the existing ones if the Entity have them, etc.)
PS: Sorry about my bad english I'm a spanish speaker
@lifo101
Copy link
Owner

lifo101 commented Dec 13, 2016

I can't remember why that logic check is there, but your changes assume that the entity always has a __toString method, which is not a good assumption.

The problem seems to come when child is null (because it tries to set _id to child.id). So I went back to the previous logic but added the case child == null that sets _id to null
@lifo101
Copy link
Owner

lifo101 commented Dec 13, 2016

I'm not convinced this is a proper 'fix'. I haven't had any issues using the Type with single or multiple form fields. I'll have to think about it.

@@ -56,7 +56,7 @@

{% block entity_typeahead_list_widget %}
{% spaceless %}
{% if simple %}
{% if simple or child == null %}
{% set _id, _value, _render = child, child, child %}
{% else %}
{% set _id, _value, _render = child.id, attribute(child, property ?: 'id'), attribute(child, render) %}
Copy link

@ahoulgrave ahoulgrave Dec 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here child var can be null (L31). cannot call any property without asking if null.

@lifo101
Copy link
Owner

lifo101 commented Dec 14, 2016 via email

@ahoulgrave
Copy link

What about L31? You're setting it to null

@lethak
Copy link

lethak commented Dec 29, 2016

I can confirm having this issue myself. I will not spend much time on it since I just found out "This bundle does not use the newer Twitter/Typeahead.js javascript library" that I thought it was. (I know, RTFM, sorry).

gonzalocelina and others added 10 commits November 13, 2017 05:39
When multiple child is set to null (line 30) and on line 62 is called child.id
That comprobation throws an error. I don't fully understand why it calls for child.id because after I quit this if() the field started working and it does everything that it should do (adds the <ul>, saves on the DB, list the existing ones if the Entity have them, etc.)
PS: Sorry about my bad english I'm a spanish speaker
The problem seems to come when child is null (because it tries to set _id to child.id). So I went back to the previous logic but added the case child == null that sets _id to null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants