-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: master
Are you sure you want to change the base?
Fix for multiple option #18
Conversation
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
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
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) %} |
There was a problem hiding this comment.
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
.
I don't see how `child` is even null in your case. when you build your form
or your controller route is possibly adding a null entity?
…-- Jason
On Tue, Dec 13, 2016 at 7:03 PM, Agustín Houlgrave ***@***.*** > wrote:
***@***.**** commented on this pull request.
------------------------------
In Resources/views/Form/typeahead.html.twig
<#18 (review)>
:
> @@ -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) %}
here child var can be null (L31). cannot call any property without asking.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWa6S8nfqPHT3pYwrg1BTfghp6-6RCFks5rHzI2gaJpZM4LL6uT>
.
|
What about L31? You're setting it to |
Fix required set
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). |
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
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