# CASE: use default in a variable

**URL:** <https://community.silverfin.com/t/case-use-default-in-a-variable/892>\
**Category:** Cases\
**Tags:** case, attribute\_default\
**Created:** [May 17, 2018, 11:36am UTC](https://community.silverfin.com/t/case-use-default-in-a-variable/892 "2018-05-17T11:36:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [May 17, 2018, 11:36am UTC](https://community.silverfin.com/t/case-use-default-in-a-variable/892/1 "2018-05-17T11:36:37Z")

</div>

Let’s say we want to display the name of the street of the file. As you know, both name and number is saved into one field `{{ company.street }}`.  
We can use the remove-tag however to strip any number that is saved into that object, by doing this:

```auto
{% assign company_city = company.street | remove:"1" | remove:"2" | remove:"3" | remove:"4" | remove:"5" | remove:"6" | remove:"7" | remove:"8" | remove:"9" | remove:"0" %}

Street = {{ company_city }} 

```

This will work in 95% of the cases, but if your street-address is “Gaston Crommenlaan 12 bus 3”, you’ll end up with this:  
 ![04](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/4c2aca2b988bc254a608818899c06665114835ae.png)

We cannot make code to have this functioning 100% (that’s an honest fact). We can however create an input-object that displays the value of our variable `company_street` where the user can overwrite the value in it (if it’s indeed mistaken and has to be corrected):

```auto
{% input custom.vkt_1.street | default:company_city %} 

```

which gives this, where the user can change the data, if needed:

![32](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/e4d3dd48e5fcd225c35698c3947f24480feb2b8d.png)

The default-tag **displays the value** in our objects, but **never actually fills** the objects with that value! You can test this by using the object further in your template: it won’t show the default-value, because in reality it’s empty!  
If you change the default-value however, by changing it or put in a new name, only then will the data been stored into the object. Because only then are you actually putting in data.  
An input-tag will never put in the default-value into an object; that’s simply how it works. It has to be inputted for that, and a default is not really inputted (only being displayed).

If you want to go around this, and let the default-value display no matter if you’ve changed the data or not, you can assign it into a variable with the default-tag like this:

```auto
{% assign street = custom.vkt_1.street | default:company_city %}

_Company-info:_

{{ street }} 

```

No matter if you change the object or not, it’ll always display and have the correct data into its object!
