本文整理汇总了PHP中Illuminate\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->bindShared('form', function ($app) {
$form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());
return $form->setSessionStore($app['session.store']);
});
}
示例2: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('form', function ($app) {
$form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());
return $form->setSessionStore($app['session.store']);
});
$this->app->singleton('html', function ($app) {
return new HtmlBuilder($app['url']);
});
}
示例3: hasMacro
/**
* Checks if macro is registered
*
* @param string $name
* @return boolean
* @static
*/
public static function hasMacro($name)
{
return \Illuminate\Html\FormBuilder::hasMacro($name);
}
示例4: registerFormIfHeeded
/**
* Add Laravel Form to container if not already set
*/
private function registerFormIfHeeded()
{
if (!$this->app->offsetExists('form')) {
$this->app->bindShared('form', function ($app) {
$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', 'Illuminate\\Html\\FormFacade');
}
}
}
示例5: button
public function button($value = null, $options = array())
{
if (strpos(@$options['class'], 'btn') === false) {
@($options['class'] .= ' btn btn-default');
}
return parent::password($value, $options);
}
示例6: render
/**
* Render the form for a given action or the default form.
*
* @param string $action
* @param array $attributes
*
* @return string
*/
public function render($action = null, array $attributes = array())
{
$renderer = $this->getRenderer();
$html = $this->open($action, $attributes);
$html .= $renderer->render($this->getFields());
$html .= $this->builder->close();
return $html;
}
示例7: getLabelFor
/**
* Get the label for a field
*
* @param InputInterface $field
* @param string $id
* @param array $attributes
*
* @return string|boolean
*/
public function getLabelFor(InputInterface $field, $id, array $attributes = array())
{
$label = $field->getLabel();
if ($label) {
return $this->builder->label($id, $label, $attributes);
}
return false;
}
示例8: close
public function close()
{
return sprintf('<div class="form-group">
<button type="submit"
class="btn btn-success btn-block btn-loading"
data-loading="<span class=\'glyphicon glyphicon-refresh spinning\'></span>">حفظ
</button>
</div>%s', parent::close());
}
示例9: input
/**
* Create the input group for an element with the correct classes for errors.
*
* @param string $type
* @param string $name
* @param string $label
* @param string $value
* @param array $options
* @return string
*/
public function input($type, $name, $label = null, $value = null, $options = array())
{
$label = $this->getLabelTitle($label, $name);
$options = $this->getFieldOptions($options);
$wrapperOptions = array('class' => $this->getRightColumnClass());
$inputElement = $type == 'password' ? $this->form->password($name, $options) : $this->form->{$type}($name, $value, $options);
$groupElement = '<div ' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . $this->getFieldError($name) . '</div>';
return $this->getFormGroup($name, $label, $groupElement);
}
示例10: select
/**
* Create a select box field.
*
* @param string $name
* @param array $list
* @param string $selected
* @param array $options
* @return string
*/
public function select($name, $list = array(), $selected = null, $options = array(), $label = '')
{
if (!self::$is_bootstrap) {
return parent::select($name, $list, $selected, $options);
}
$label_text = $label == '' ? $this->transformKey($name) : $label;
$options = $this->appendClassToOptions('form-control', $options);
// Call the parent select method so that Laravel can handle
// the rest of the select set up.
return $this->openGroup($name, $label_text) . parent::select($name, $list, $selected, $options) . $this->closeGroup($name);
}
示例11: buttonField
/**
* @param Field $field
* @param string $type
* @return string
*/
public function buttonField(Field $field, $type = 'button')
{
$attributes = $field->getAttributes();
$attributes['type'] = $type;
if ($field->label) {
$value = $field->label;
$attributes['value'] = $field->value;
} else {
$value = $field->value;
}
return $this->builder->button($value, $attributes);
}
示例12: select
/**
* Generate a select field.
*
* @param $name
* @param string $value
* @param array $options
*
* @return string
*/
public function select($name, $value = null, $options = [])
{
$select_options = [];
// Loop through, and pluck out the select box list options
// from the $options array, then remove the select options.
foreach ($options as $key => $label) {
if (is_array($label)) {
$select_options = $label;
unset($options[$key]);
}
}
return $this->formBuilder->select($name, $select_options, $value, $options);
}
示例13: open
/**
* Open up a new HTML form and includes a session key.
* @param array $options
* @return string
*/
public function open(array $options = [])
{
$method = strtoupper(array_get($options, 'method', 'post'));
$request = array_get($options, 'request');
$model = array_get($options, 'model');
if ($model) {
$this->model = $model;
}
$append = $this->requestHandler($request);
if ($method != 'GET') {
$append .= $this->sessionKey(array_get($options, 'sessionKey'));
}
return parent::open($options) . $append;
}
示例14: options
/**
* Create a form select field.
*
* @param string $name
* @param string $label
* @param array $list
* @param string $selected
* @param \Illuminate\Support\MessageBag $errors
* @param array $options
*
* @return string
*/
protected function options($name, $label = null, array $list = array(), $selected = null, $errors = null, array $options = array())
{
$options = array_merge(array('class' => 'form-control'), $options);
$return = $this->group($name, $errors);
$return .= $this->label($name, $label);
if ($this->formType == self::FORM_HORIZONTAL) {
$return .= $this->group('', null, $this->inputClass);
}
$return .= $this->form->select($name, $list, $selected, $options) . "\n";
$return .= $this->errors($name, $errors);
if ($this->formType == self::FORM_HORIZONTAL) {
$return .= '</div>' . "\n";
}
$return .= '</div>' . "\n";
return $return;
}
示例15: testElements
public function testElements()
{
$this->getApplicationMock()->expects($this->exactly(1))->method('make')->with('form')->will($this->returnValue($this->formBuilderMock));
$this->testInstance->setMeta($this->metaAttributesMock);
$this->metaAttributesMock->__value = uniqid();
$this->metaAttributesMock->setLocale('_');
$testMethods = ['open', 'select', 'close', 'submit', 'hidden', 'checkbox', 'radio', 'text', 'password', 'textarea'];
foreach ($testMethods as $testMethod) {
$this->formBuilderMock->expects($this->exactly(1))->method($testMethod);
}
$this->assertSame("<label>label</label>", (string) $this->testInstance->label('label'));
$this->testInstance->open();
$this->testInstance->close();
$this->testInstance->select('value');
$this->testInstance->submit('value');
$this->testInstance->hidden('value');
$this->testInstance->checkbox('value');
$this->testInstance->radio('value');
$this->testInstance->text('value');
$this->testInstance->textarea('value');
$this->testInstance->password('value');
}