Yii2 Format Attributes

0

a query, there is some way to format an attribute in the model either before it is saved or when the query is made. The idea is that for example when it comes to bringing a date, it is formatted to a d-m-yy format to be able to use it directly or in a contrary case that a description attribute beyond if it is an insert or update always enter with capital letters. If possible, could you give me an example? Thanks

    
asked by Pablo JS 25.10.2018 в 01:26
source

1 answer

0

To show an attribute of a previous formatting model you can in the model overwrite the getAtributo method

If you have an attribute called name and you want it always to be capitalized you can in the model

  

public function getName () {      return strtoupper ($ this-> name);   }

    
answered by 07.01.2019 в 17:32