本文整理汇总了PHP中Nette\Forms\Form::extensionMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::extensionMethod方法的具体用法?PHP Form::extensionMethod怎么用?PHP Form::extensionMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::extensionMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Register Antispam to Nette Forms
* @return void
*/
public static function register()
{
Form::extensionMethod('addAntispam', function (Form $form, $name = 'spam', $label = 'Toto pole vymažte', $msg = 'Byl detekován pokus o spam.') {
// "All filled" protection
$form[$name] = new AntispamControl($label, NULL, NULL, $msg);
// "Send delay" protection
$form->addHidden('form_created', strtr(time(), '0123456789', 'jihgfedcba'))->addRule(function ($item) {
if (AntispamControl::$minDelay <= 0) {
return TRUE;
}
// turn off "Send delay protection"
$value = (int) strtr($item->value, 'jihgfedcba', '0123456789');
return $value <= time() - AntispamControl::$minDelay;
}, $msg);
return $form;
});
}
示例2: register
/**
* Adds addTag() method to \Nette\Forms\Form
*/
public static function register()
{
Form::extensionMethod('addTag', callback(__CLASS__, 'addTag'));
}
示例3: function
// Configure application
$configurator = new Nette\Configurator();
// Enable Nette Debugger for error visualisation & logging
//$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/../log');
// Enable RobotLoader - this will load all classes automatically
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register();
// Create Dependency Injection container from config.neon file
$environment = Nette\Configurator::detectDebugMode('127.0.0.1') ? $configurator::DEVELOPMENT : $configurator::PRODUCTION;
$configurator->addConfig(__DIR__ . '/config/config.neon', $environment);
$container = $configurator->createContainer();
$container->application->errorPresenter = 'Error';
// DatePicker
\Nette\Forms\Form::extensionMethod('addDatePicker', function (Nette\Forms\Form $_this, $name, $label = NULL, $cols = NULL, $maxLength = NULL) {
return $_this[$name] = new RadekDostal\NetteComponents\DateTimePicker\DatePicker($label, $cols, $maxLength);
});
// Setup router
// Admin Router
$container->router[] = $adminRouter = new RouteList();
$adminRouter[] = new Route('admin/<presenter>/<action>/<id>', array('module' => 'Admin', 'presenter' => 'Default', 'action' => 'default'));
$adminRouter[] = new Route('admin/<presenter>/<action>', array('module' => 'Admin', 'presenter' => 'Default', 'action' => 'default', 'id' => NULL));
// Front Router
$container->router[] = $frontRouter = new RouteList();
$frontRouter[] = new Route('index.php', array('presenter' => 'Default'), Route::ONE_WAY);
$frontRouter[] = new Route('', array('lang' => 'cs', 'presenter' => 'Default'), Route::ONE_WAY);
$frontRouter[] = new Route('files/vydavatele/certifikat.html', array('presenter' => 'Default', 'action' => 'disclaimer', 'lang' => 'cs'), Route::ONE_WAY);
$frontRouter[] = new Route('certifikat', array('presenter' => 'Default', 'action' => 'graphics', 'lang' => 'cs'), Route::ONE_WAY);
$frontRouter[] = new Route('<lang en|cs>', array('presenter' => 'Default', 'action' => 'default', 'id' => NULL));
/*$frontRouter[] = new Route('cs/klicove-slovo/<keyword>', array(
'presenter' => 'Default',