/** * ColorPicker::ColorPicker() * * Constructor: Create a new ColorPicker object * * @param object $form The form where this field is located on * @param string $name The name of the field * @return \FormHandler\Field\ColorPicker * @author Rick den Haan */ public function __construct($form, $name) { parent::__construct($form, $name); static $bSetJS = false; // needed javascript included yet ? if (!$bSetJS) { // include the needed javascript $bSetJS = true; $form->_setJS(\FormHandler\Configuration::get('fhtml_dir') . "js/jscolor/jscolor.js", true); } return $this; }
/** * Constructor * * Create a new text field * * @param FormHandler $form The form where this field is located on * @param string $name The name of the field * @return \FormHandler\Field\Text * @author Teye Heimans * @author Marien den Besten */ public function __construct(FormHandler $form, $name) { static $bCaptcha = true; if (!$bCaptcha) { trigger_error("Please use only one Captcha field on a page", E_USER_WARNING); } $bCaptcha = false; if (!isset($_SESSION)) { trigger_error("Please make sure you have an active session", E_USER_WARNING); } $this->image = new \FormHandler\Button\Image($form, $name . '_image'); $this->image->setExtra('onclick="return false;" style="cursor:default;"'); // call the constructor of the Field class parent::__construct($form, $name)->setSize(\FormHandler\Configuration::get('captcha_length'))->setWidth(\FormHandler\Configuration::get('captcha_width'))->setMaxlength(0)->setValidator(new \FormHandler\Validator\FunctionCallable(function ($value) { require_once __DIR__ . '/../FHTML/securimage/securimage.php'; $img = new \Securimage(); $valid = $img->check($value); return $valid == true; }))->setRequired(true); }