| @@ 227-259 (lines=33) @@ | ||
| 224 | * @return string |
|
| 225 | * @since 2.0 |
|
| 226 | */ |
|
| 227 | public function prepare( $options = null ) { |
|
| 228 | ||
| 229 | $format = self::$prepare; |
|
| 230 | ||
| 231 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
| 232 | ||
| 233 | if ( $length < 1 || 64 < $length ) { |
|
| 234 | $length = 64; |
|
| 235 | } |
|
| 236 | ||
| 237 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
| 238 | ||
| 239 | if ( $decimals < 1 ) { |
|
| 240 | $decimals = 0; |
|
| 241 | } |
|
| 242 | elseif ( 30 < $decimals ) { |
|
| 243 | $decimals = 30; |
|
| 244 | } |
|
| 245 | ||
| 246 | if ( $length < $decimals ) { |
|
| 247 | $decimals = $length; |
|
| 248 | } |
|
| 249 | ||
| 250 | if ( 0 < $decimals ) { |
|
| 251 | $format = '%01.' . $decimals . 'F'; |
|
| 252 | } |
|
| 253 | else { |
|
| 254 | $format = '%d'; |
|
| 255 | } |
|
| 256 | ||
| 257 | return $format; |
|
| 258 | ||
| 259 | } |
|
| 260 | ||
| 261 | /** |
|
| 262 | * Change the way the value of the field is displayed with Pods::get |
|
| @@ 177-201 (lines=25) @@ | ||
| 174 | * @return array |
|
| 175 | * @since 2.0 |
|
| 176 | */ |
|
| 177 | public function prepare ( $options = null ) { |
|
| 178 | $format = self::$prepare; |
|
| 179 | ||
| 180 | $length = (int) pods_var( self::$type . '_max_length', $options, 12, null, true ); |
|
| 181 | ||
| 182 | if ( $length < 1 || 64 < $length ) |
|
| 183 | $length = 64; |
|
| 184 | ||
| 185 | $decimals = (int) pods_var( self::$type . '_decimals', $options, 0, null, true ); |
|
| 186 | ||
| 187 | if ( $decimals < 1 ) |
|
| 188 | $decimals = 0; |
|
| 189 | elseif ( 30 < $decimals ) |
|
| 190 | $decimals = 30; |
|
| 191 | ||
| 192 | if ( $length < $decimals ) |
|
| 193 | $decimals = $length; |
|
| 194 | ||
| 195 | if ( 0 < $decimals ) |
|
| 196 | $format = '%01.' . $decimals . 'f'; |
|
| 197 | else |
|
| 198 | $format = '%d'; |
|
| 199 | ||
| 200 | return $format; |
|
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * Change the way the value of the field is displayed with Pods::get |
|