Fix for multiple option#18
Open
gonzalocelina wants to merge 14 commits into
Open
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
Owner
|
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
Owner
|
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. |
ahoulgrave
reviewed
Dec 14, 2016
| {% 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.
here child var can be null (L31). cannot call any property without asking if null.
Owner
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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