[TwigComponent] Defaulted options of a resolver are removed from the passed data when they're not set #2989
              
                Unanswered
              
          
                  
                    
                      HugoLandrin
                    
                  
                
                  asked this question in
                Questions & Answers
              
            Replies: 2 comments
-
| Hi, shouldn't you return  | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| 
 
 Resolved option do retain their defaulted values. But resolved options and mounted props are two different things, and as you said, you have no props, so.... 🤷 | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When resolving your data through an
OptionsResolverin aPreMountevent of a twig component, options that are set to have a default value get erased from the data array passed to the rendered twig template when they have no data attached.Important
I am not using class props.
The component class:
The component Twig file:
{% if path is not null %} <a href="{{ path }}" {% else %} <button {% endif %} ... {% if path is not null %} </a> {% else %} </button> {% endif %}Error:
Variable "path" does not exist in _components/button.html.twigImportant
This does not occur when manually setting the parameter when calling the component
Resolved options should retain their defaulted values when they are set to null, just like any other use case of the
OptionsResolver.Beta Was this translation helpful? Give feedback.
All reactions