Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
 1 <?php
 2 /**
 3  * FloatInput.php
 4  *
 5  * @author  Elvyrra SAS
 6  * @license http://rem.mit-license.org/ MIT
 7  */
 8 
 9 namespace Hawk;
10 
11 /**
12  * This class describes input that must contain float values
13  *
14  * @package Form\Input
15  */
16 class FloatInput extends NumberInput{
17 
18     /**
19      * The number of decimals to display
20      *
21      * @var integer
22      */
23     public $decimals = 2;
24 
25     /**
26      * Constructor
27      *
28      * @param array $param The input parameters
29      */
30     public function __construct($param){
31         parent::__construct($param);
32         $this->pattern = '/^[0-9]+(.[0-9]{0, ' . $this->decimals  .'})?/';
33     }
34 
35 
36     /**
37      * Display the input
38      *
39      * @return string The displayed HTML
40      */
41     public function display(){
42         $this->value = number_format(floatval($this->value), $this->decimals, ".", "");
43         return parent::display();
44     }
45 
46 
47     /**
48      * Check the format of the submitted value
49      *
50      * @param Form $form The form the input is associated with
51      *
52      * @return boolean true if the submitted value has the right syntax, else false
53      */
54     public function check(&$form = null){
55         if(parent::check($form)) {
56             if(!empty($this->value) && !is_numeric($this->value)) {
57                 // The value is not numeric
58                 $form->error($this->errorAt, Lang::get('form.number-format'));
59                 return false;
60             }
61             return true;
62         }
63         else{
64             return false;
65         }
66     }
67 
68     /**
69      * Get the value, formatted for the MySQL database
70      *
71      * @return float The formatted value
72      */
73     public function dbvalue(){
74         return (float)($this->value);
75     }
76 }
77 
Hawk - PHP documentation API documentation generated by ApiGen