| @@ 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 |
|
| @@ 227-259 (lines=33) @@ | ||
| 224 | * @return array |
|
| 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 |
|