本文整理汇总了PHP中Collective\Html\FormBuilder类的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder类的具体用法?PHP FormBuilder怎么用?PHP FormBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerFormBuilder
/**
* Register the form builder instance.
*
* @return void
*/
protected function registerFormBuilder()
{
$this->app->singleton('form', function ($app) {
$form = new FormBuilder($app['html'], $app['url'], $app['view'], $app['session.store']->getToken());
return $form->setSessionStore($app['session.store']);
});
}
示例2: registerFormBuilder
/**
* Register the form builder instance.
*
* @return void
*/
protected function registerFormBuilder()
{
$this->app->singleton('form', function ($app) {
/** @var Store $session */
$session = $app['session.store'];
$form = new FormBuilder($app['html'], $app['url'], $session->token());
$form->setSessionStore($session);
return $form;
});
$this->app->alias('form', 'Collective\\Html\\FormBuilder');
}
示例3: register
/**
* Register any application services.
*
* This service provider is a great spot to register your various container
* bindings with the application. As you can see, we are registering our
* "Registrar" implementation here. You can add your own bindings too!
*
* @return void
*/
public function register()
{
parent::register();
FormBuilder::macro('template', function ($template, $empty = false, $field = 'template') {
$template_list = '';
if ($empty) {
$template_list[''] = '-';
}
$folder = base_path() . '/resources/views/site/';
if (is_dir($folder)) {
$iterator = new \DirectoryIterator($folder);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile() && !$fileinfo->isDot()) {
$file = explode('.', $fileinfo->getFilename());
array_pop($file);
$value = implode('.', $file);
$template_list[$value] = $value;
}
}
}
if ($template_list) {
return Form::select($field, $template_list, $template, ['class' => "form-control"]);
}
return '';
});
}
示例4: registerFormSubmit
private function registerFormSubmit()
{
FormBuilder::macro('button_submit', function ($texte) {
return FormBuilder::submit($texte, ['class' => 'btn btn-info pull-right']);
});
}
示例5: hasMacro
/**
* Checks if macro is registered.
*
* @param string $name
* @return bool
* @static
*/
public static function hasMacro($name)
{
return \Collective\Html\FormBuilder::hasMacro($name);
}
示例6: register
/**
* Register the application services.
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'laform');
$this->app->bind('laform', 'Karan\\Laform\\Laform');
if (!$this->app->offsetExists('form')) {
$this->app->singleton('form', function ($app) {
// LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exeption
// https://github.com/kristijanhusak/laravel-form-builder/commit/a36c4b9fbc2047e81a79ac8950d734e37cd7bfb0
if (substr(Application::VERSION, 0, 3) == '5.2') {
$form = new LaravelForm($app['html'], $app['url'], $app['view'], $app['session.store']->getToken());
} else {
$form = new LaravelForm($app['html'], $app['url'], $app['session.store']->getToken());
}
return $form->setSessionStore($app['session.store']);
});
if (!$this->aliasExists('Form')) {
AliasLoader::getInstance()->alias('Form', 'Collective\\Html\\FormFacade');
}
}
if (!$this->app->offsetExists('html')) {
$this->app->singleton('html', function ($app) {
return new HtmlBuilder($app['url'], $app['view']);
});
if (!$this->aliasExists('Html')) {
AliasLoader::getInstance()->alias('Html', 'Collective\\Html\\HtmlFacade');
}
}
}
示例7: registerFormIfHeeded
/**
* Add Laravel Form to container if not already set
*/
private function registerFormIfHeeded()
{
if (!$this->app->offsetExists('form')) {
$this->app->singleton('form', function ($app) {
$form = new LaravelForm($app['html'], $app['url'], $app['view'], $app['session.store']->getToken());
return $form->setSessionStore($app['session.store']);
});
if (!$this->aliasExists('Form')) {
AliasLoader::getInstance()->alias('Form', 'Collective\\Html\\FormFacade');
}
}
}
示例8: open
/**
* Open up a new HTML form and pass the optional novalidate option.
* This methods relies on the original Form::open method of the Laravel
* Collective component.
*
* @param array $options
*
* @return string
*/
public function open(array $options = array())
{
if ($this->novalidate()) {
$options[] = 'novalidate';
}
return parent::open($options);
}
示例9: open
/**
* @param array $options
*
* @return string
*/
public function open(array $options = [])
{
$themeName = array_get($options, 'theme', config('rutorika-form.theme'));
$themeClass = config('rutorika-form.themes.' . $themeName);
$this->theme = new $themeClass($this);
$options = $this->theme->updateOptions($options);
return parent::open($options);
}
示例10: commonInputs
private function commonInputs($type, $name, $value = null, $options = [])
{
return sprintf('
<div class="input-field col l6 s8 offset-l3 offset-s2">
%s
%s
</div>', parent::input($type, $name, $value, $options), parent::label($name, null, []));
}
示例11: getErrors
/**
* Get the MessageBag of errors that is populated by the
* validator.
*
* @return \Illuminate\Support\ViewErrorBag
*/
protected function getErrors()
{
$errors = $this->form->getSessionStore()->get('errors');
if ($errors) {
return $errors->getBag($this->errorBag);
}
return $errors;
}
示例12: selection
public function selection($nom, $list = [], $selected = null, $label = null)
{
return sprintf('
<div class="form-group" style="width:200px;">
%s
%s
</div>', $label ? $this->label($nom, $label, ['class' => 'control-label']) : '', parent::select($nom, $list, $selected, ['class' => 'form-control']));
}
示例13: open
public function open(array $options = [])
{
if (array_key_exists('model', $options)) {
PkForm::setModel($options['model']);
unset($options['model']);
}
return parent::open($options);
}
示例14: textarea
public function textarea($name, $value = null, $options = [])
{
return sprintf('
<div class="input-field col l6 s8 offset-l3 offset-s2">
%s
%s
</div>', parent::textarea($name, $value, ['class' => 'materialize-textarea']), parent::label($name, null, []));
}
示例15: close
public function close()
{
$results = '';
if (Generator::END == $this->gen->getCodePosition()) {
$results .= $this->generateClientValidatorCode();
}
$results .= parent::close();
return $results;
}