コード例 #1
0
 public function setValidator($validator = null)
 {
     if (count($this->getValidators()) === 0 && $validator instanceof FormHandler\Validator\FunctionCallable && is_array($validator->getCallable())) {
         $callable = $validator->getCallable();
         //detect if it is an optional validator
         if ($callable[0] instanceof Validator && substr($callable[1], 0, 1) !== '_') {
             parent::setValidator(new \FormHandler\Validator\NotEmpty());
         }
     }
     return parent::setValidator(FormHandler::parseValidator($validator, $this));
 }
コード例 #2
0
 /**
  * getField()
  *
  * Return the HTML of the field
  *
  * @return string the html
  * @access public
  * @author Teye Heimans
  */
 public function getField()
 {
     $this->setExtraAfter('%');
     // view mode enabled ?
     if ($this->getViewMode()) {
         // get the view value..
         return $this->_getViewValue() . (is_null($this->getValue()) ? '' : '%');
     }
     //formhandler can not handle objects yet
     return parent::getField();
 }
コード例 #3
0
ファイル: helptext.php プロジェクト: FormHandler/FormHandler
 * 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)->setHelp('Help text', 'Help title');
Field\Number::set($form, 'Age', 'age')->setValidator(new Validator\Integer())->setMin(1)->setMax(110)->setStep(1)->setHelp('Help text without title');
//button for submitting
Button\Submit::set($form, 'Send');
//set the 'commit-after-form' function
$form->onCorrect(function ($data) {
    return "Hello " . $data['name'] . ", you are " . $data['age'] . " years old!";
});
//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 the help icon<hr>';
echo $form_html;
コード例 #4
0
ファイル: basic.php プロジェクト: FormHandler/FormHandler
 * 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
 */
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')->setRequired(true)->setMaxlength(40);
Field\Number::set($form, 'Age', 'age')->setRequired(true)->setValidator(new Validator\Integer())->setMin(1)->setMax(110)->setStep(1);
//button for submitting
Button\Submit::set($form, 'Send');
//set the 'commit-after-form' function
$form->onCorrect(function ($data) {
    return "Hello " . $data['name'] . ", you are " . $data['age'] . " years old!";
});
//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 'Basic FormHandler demo<hr>';
echo $form_html;
コード例 #5
0
ファイル: Length.php プロジェクト: FormHandler/FormHandler
 /**
  * Set disabled
  *
  * @param boolean $bool
  * @return \FormHandler\Field\Field
  */
 public function setDisabled($bool = true)
 {
     $this->length->setDisabled($bool);
     $this->unit->setDisabled($bool);
     return parent::setDisabled($bool);
 }