*
 * 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/');
$form = new FormHandler();
$form->addLine('<br>Button with custom confirmation handler', true);
Button\Button::set($form, 'Click me!', 'btn_4')->setConfirmation('Do you really want to click this button?')->setConfirmationDescription('And some extra description')->setExtra('onclick="alert(\'Custom handler successfully executed\')"');
$form->addHTML('<div id="testResult"></div>');
//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 'Test for custom button confirmation handler<hr>
' . $form_html . '
<script>
    $(document).ready(function()
    {
        var div = $("#testResult"),
        confirm = function(message, description, callable, options)
        {
            if(div.hasClass(\'active\'))
            {
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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/');
$form = new FormHandler();
$form->addLine('Button with confirmation on click', true);
Button\Submit::set($form, 'Button 1', 'btn_1');
Button\Submit::set($form, 'Button 2', 'btn_2');
Button\Submit::set($form, 'Button 3', 'btn_3');
$form->onCorrect(function ($data, FormHandler $form) {
    return 'Button "' . $form->getButtonClicked() . '" clicked';
});
//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 'Test for reading out which button has been click in the onCorrect<hr>';
echo $form_html;
예제 #3
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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 Marien den Besten
 */
session_start();
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();
$form->addLine('Fill captcha', true);
Field\Captcha::set($form, 'Required captcha', 'captcha');
$form->onCorrect(function ($data) {
    echo 'Captcha field working!';
});
Button\Submit::set($form);
//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 'Test captcha field<hr>';
echo $form_html;