formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 204 forks source link

Question: Custom fields? #565

Closed Nav33d closed 6 years ago

Nav33d commented 6 years ago

Hi,

I was wondering if it is possible to add a custom fields?

Many thanks

claar commented 6 years ago

Can you give a concrete example of what you're thinking? Perhaps some HTML of expected output from Former?

Nav33d commented 6 years ago

I don't have anything specific in my mind but something like a DateTime field which displays a calendar to select date or field to attache other model entries?

Appreciate your quick response!

Many thanks

claar commented 6 years ago

Hi @Nav33d; there are several ways to support custom elements in Former, depending on the exact element in question. Most things like DateTime fields are added using JavaScript libraries, and Former makes it easy to use such libraries via customization of the HTML it outputs:

<?php
echo Former::text('foo')->raw(); // Print an input without surrounding div's
echo Former::text('foo')->addClass('bar'); // Add a custom class to an element (for JS libraries)
echo Former::text('foo')->onGroupAddClass('bar'); // Add a custom class to the container element