@@ 250-282 (lines=33) @@ | ||
247 | * @return array |
|
248 | * @since 2.0 |
|
249 | */ |
|
250 | public function prepare( $options = null ) { |
|
251 | ||
252 | $format = self::$prepare; |
|
253 | ||
254 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
255 | ||
256 | if ( $length < 1 || 64 < $length ) { |
|
257 | $length = 64; |
|
258 | } |
|
259 | ||
260 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
261 | ||
262 | if ( $decimals < 1 ) { |
|
263 | $decimals = 0; |
|
264 | } |
|
265 | elseif ( 30 < $decimals ) { |
|
266 | $decimals = 30; |
|
267 | } |
|
268 | ||
269 | if ( $length < $decimals ) { |
|
270 | $decimals = $length; |
|
271 | } |
|
272 | ||
273 | if ( 0 < $decimals ) { |
|
274 | $format = '%01.' . $decimals . 'F'; |
|
275 | } |
|
276 | else { |
|
277 | $format = '%d'; |
|
278 | } |
|
279 | ||
280 | return $format; |
|
281 | ||
282 | } |
|
283 | ||
284 | /** |
|
285 | * Change the way the value of the field is displayed with Pods::get |
@@ 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 |