Пример #1
0
 /**
  * Method to instantiate the form field object.
  *
  * @param   object  $form  The form to attach to the form field object.
  * @return  void
  */
 public function __construct($form = null)
 {
     // If there is a form passed into the constructor set the form and form control properties.
     if ($form instanceof Form) {
         $this->form = $form;
         $this->formControl = $form->getFormControl();
     }
     // Detect the field type if not set
     if (!isset($this->type)) {
         // Get the reflection info
         $r = new ReflectionClass($this);
         // Is it namespaced?
         if ($r->inNamespace()) {
             // It is! This makes things easy.
             $this->type = $r->getShortName();
         } else {
             // We'll assume a CamelCased name
             // Split by words and take the last one
             $parts = String::splitCamel(get_class($this));
             if ($parts[0] == 'J') {
                 $this->type = ucfirst($parts[count($parts) - 1], '_');
             } else {
                 $this->type = ucfirst($parts[0], '_') . ucfirst($parts[count($parts) - 1], '_');
             }
         }
     }
 }