public static function set(\FormHandler\FormHandler $form, $title, $name, $validator = null) { $field = parent::set($form, $title, $name); $field->setValidator(FormHandler::parseValidator($validator, $field)); return $field; }
* Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA * * @author Ruben de Vos */ include '../src/Loader.php'; use FormHandler\FormHandler; use FormHandler\Field; use FormHandler\Button; use FormHandler\Validator; \FormHandler\Configuration::set('fhtml_dir', '../src/FHTML/'); //create a new FormHandler object $form = new FormHandler(); //some fields.. (see manual for examples) Field\Text::set($form, 'Name', 'name')->setValidator(new Validator\String())->setMaxlength(40); Field\ColorPicker::set($form, 'Color', 'color'); //button for submitting Button\Submit::set($form, 'Send'); //set the 'commit-after-form' function $form->onCorrect(function ($data) { return "Hello " . $data['name'] . ", you picked the color " . $data['color'] . "!"; }); //process all form results, needs to be done before any output has been done $form_html = $form->flush(); //below is code to show the form echo 'Color Picker demo<hr>'; echo $form_html;
/** * FormHandler::colorPicker() * * Creates a colorpicker on the form * * @param string $title The title of the field * @param string $name The name of the field * @param string $validator The validator which should be used to validate the value of the field * @param int $size The size of the field * @param int $maxlength The allowed max input of the field * @param string $extra CSS, Javascript or other which are inserted into the HTML tag * @return \FormHandler\Field\ColorPicker * @author Johan Wiegel * @since 23-10-2008 * @deprecated Use \FormHandler\Field\ColorPicker::set() instead */ public function colorPicker($title, $name, $validator = null, $size = null, $maxlength = null, $extra = null) { $field = \FormHandler\Field\ColorPicker::set($this, $title, $name); return $field->setValidator(self::parseValidator($validator, $field))->setSize($size)->setMaxlength($maxlength)->setExtra($extra); }