Input fields: attributes (placeholder, default & assign)
Apart from the variable name, our input tag can contain different attributes that can modify the field’s behaviour. The main one is the “as” attribute that defines the data type:
A placeholder is a watermark that appears in our input field as hint for the user on what it needs to be entered. By default, the placeholder is the key but we can overwrite this with an attribute. This hint is not saved in the database and it doesn’t get assigned as a value for the particular input variable.
A default is an attribute in an input that shows a certain value when the user has not entered any data (i.e. the field is blank). This default value is only displayed in the template but not saved on the database. So, if we try to print the variable, the output will be blank. The default value is shown with a dotted line underneath
When the default value has been overwritten, a yellow triangle will show on the top left, and the dotted line will no longer appear. The database variable is no longer blank.
Sometimes we want the default value to be printed or to be taken into consideration when making calculations. In order to do this we need to use the assign attribute that will create a variable containing the default value
Updated almost 2 years ago