Back to FormField class

Method __construct

public
__construct
(mixed $form = null)
Method to instantiate the form field object.
Parameters
  • \Joomla\CMS\Form\Form $form The form to attach to the form field object.
Since
  • 1.7.0
Class: FormField
Project: Joomla

Method __construct - Source code

/**
 * Method to instantiate the form field object.
 *
 * @param   Form  $form  The form to attach to the form field object.
 *
 * @since   1.7.0
 */
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)) {
        $parts = Normalise::fromCamelCase(\get_called_class(), true);
        if ($parts[0] === 'J') {
            $this->type = StringHelper::ucfirst($parts[\count($parts) - 1], '_');
        } else {
            $this->type = StringHelper::ucfirst($parts[0], '_') . StringHelper::ucfirst($parts[\count($parts) - 1], '_');
        }
    }
}