| @@ 169-193 (lines=25) @@ | ||
| 166 | * @return array |
|
| 167 | * @since 2.0 |
|
| 168 | */ |
|
| 169 | public function prepare ( $options = null ) { |
|
| 170 | $format = self::$prepare; |
|
| 171 | ||
| 172 | $length = (int) pods_var( self::$type . '_max_length', $options, 12, null, true ); |
|
| 173 | ||
| 174 | if ( $length < 1 || 64 < $length ) |
|
| 175 | $length = 64; |
|
| 176 | ||
| 177 | $decimals = (int) pods_var( self::$type . '_decimals', $options, 0, null, true ); |
|
| 178 | ||
| 179 | if ( $decimals < 1 ) |
|
| 180 | $decimals = 0; |
|
| 181 | elseif ( 30 < $decimals ) |
|
| 182 | $decimals = 30; |
|
| 183 | ||
| 184 | if ( $length < $decimals ) |
|
| 185 | $decimals = $length; |
|
| 186 | ||
| 187 | if ( 0 < $decimals ) |
|
| 188 | $format = '%01.' . $decimals . 'f'; |
|
| 189 | else |
|
| 190 | $format = '%d'; |
|
| 191 | ||
| 192 | return $format; |
|
| 193 | } |
|
| 194 | ||
| 195 | /** |
|
| 196 | * Change the way the value of the field is displayed with Pods::get |
|
| @@ 249-281 (lines=33) @@ | ||
| 246 | * @return array |
|
| 247 | * @since 2.0 |
|
| 248 | */ |
|
| 249 | public function prepare( $options = null ) { |
|
| 250 | ||
| 251 | $format = self::$prepare; |
|
| 252 | ||
| 253 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
| 254 | ||
| 255 | if ( $length < 1 || 64 < $length ) { |
|
| 256 | $length = 64; |
|
| 257 | } |
|
| 258 | ||
| 259 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
| 260 | ||
| 261 | if ( $decimals < 1 ) { |
|
| 262 | $decimals = 0; |
|
| 263 | } |
|
| 264 | elseif ( 30 < $decimals ) { |
|
| 265 | $decimals = 30; |
|
| 266 | } |
|
| 267 | ||
| 268 | if ( $length < $decimals ) { |
|
| 269 | $decimals = $length; |
|
| 270 | } |
|
| 271 | ||
| 272 | if ( 0 < $decimals ) { |
|
| 273 | $format = '%01.' . $decimals . 'F'; |
|
| 274 | } |
|
| 275 | else { |
|
| 276 | $format = '%d'; |
|
| 277 | } |
|
| 278 | ||
| 279 | return $format; |
|
| 280 | ||
| 281 | } |
|
| 282 | ||
| 283 | /** |
|
| 284 | * Change the way the value of the field is displayed with Pods::get |
|