/** * Register the field with FormHandler * * @param FormHandler $form * @param string|null $caption * @param string|null $name * @param mixed $validator * @return static Instance of */ public static function set(FormHandler $form, $caption = null, $name = null) { $class = get_called_class(); $processed_name = empty($name) ? $form->getNewButtonName() : $name; // create the field $fld = new $class($form, $processed_name); $fld->setCaption($caption); // register the field $form->registerField($processed_name, $fld); return $fld; }