Ejemplo n.º 1
0
 /**
  * Get the button
  *
  * @author Marien den Besten
  * @return string
  */
 public function getButton()
 {
     $this->extra .= ' onclick="' . (is_null($this->url) ? 'history.back(-1)' : 'document.location.href=\'' . \FormHandler\Utils::url($this->url) . '\'') . '"';
     if (is_null($this->caption)) {
         $this->caption = \FormHandler\Language::get(28);
     }
     return parent::getButton();
 }
 *
 * 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\Button::set($form, 'Click me!', 'btn_1')->setConfirmation('Do you really want to click this button?');
$form->addLine('<br>Button with confirmation and description on click', true);
Button\Button::set($form, 'Click me!', 'btn_2')->setConfirmation('Do you really want to click this button?')->setConfirmationDescription('And some extra description');
$form->addLine('<br>Button with confirmation, description and alert after confirmation approved', true);
Button\Button::set($form, 'Click me!', 'btn_3')->setConfirmation('Do you really want to click this button?')->setConfirmationDescription('And some extra description')->setExtra('onclick="alert(\'This alert should be displayed after confirmation is success\');"');
//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 button confirmation<hr>';
echo $form_html;
Ejemplo n.º 3
0
 /**
  * Constructor: The constructor to create a new Submit object.
  *
  * @param object $form the form where this field is located on
  * @param string $name the name of the button
  * @return \FormHandler\Button\Submit
  * @author Teye Heimans
  */
 public function __construct($form, $name)
 {
     return parent::__construct($form, $name)->setType(self::TYPE_SUBMIT)->setCaption(\FormHandler\Language::get(26));
 }
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * @param FormHandler $form the form where the image button is located on
  * @param string $name the name of the button
  * @param string $image the image we have to use as button
  * @return \FormHandler\Button\Image
  * @author Teye Heimans
  */
 public function __construct(FormHandler $form, $name)
 {
     return parent::__construct($form, $name);
 }
 * 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\'))
            {
                return;
Ejemplo n.º 6
0
 /**
  * FormHandler::button()
  *
  * Create a button on the form
  *
  * @param string $caption The caption of the button
  * @param string $name The name of the button
  * @param string $extra CSS, Javascript or other which are inserted into the HTML tag
  * @return \FormHandler\Button\Button
  * @author Teye Heimans
  * @author Marien den Besten
  * @deprecated Use \FormHandler\Button\Button::set() instead
  */
 public function button($caption, $name = null, $extra = null, $disableOnClick = true)
 {
     $btn = \FormHandler\Button\Button::set($this, $caption, $name)->setExtra($extra);
     if (!is_null($disableOnClick)) {
         $btn->disableOnSubmit($disableOnClick);
     }
     return $btn;
 }
Ejemplo n.º 7
0
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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();
Button\Button::set($form, 'Disable Button')->setDisabled();
Button\Button::set($form, 'Disable and enable Button')->setDisabled()->setDisabled(false);
Button\Cancel::set($form, 'Disable CancelButton')->setDisabled();
Button\Reset::set($form, 'Disable ResetButton')->setDisabled();
//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 button confirmation<hr>';
echo $form_html;