作者:kartx2
项目:Otoru-Dic
/**
* 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']);
});
}
作者:ferranf
项目:laravextr
/**
* 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']);
});
}
作者:nmk
项目:basic-starte
/**
* Checks if macro is registered
*
* @param string $name
* @return boolean
* @static
*/
public static function hasMacro($name)
{
return \Illuminate\Html\FormBuilder::hasMacro($name);
}
作者:jorzhikgi
项目:MLM-Nexu
/**
* Set the session store implementation.
*
* @param \Illuminate\Session\Store $session
* @return \Illuminate\Html\FormBuilder
* @static
*/
public static function setSessionStore($session)
{
return \Illuminate\Html\FormBuilder::setSessionStore($session);
}
作者:Vatia1
项目:gbtime
* Create a select box field.
*
* @param string $name
* @param array $list
* @param string $selected
* @param array $options
* @return string
*/
FormBuilder::macro('selectMy', function ($name, $list = array(), $selected = null, $option = '', $options = array()) {
// When building a select box the "value" attribute is really the selected one
// so we will use that when checking the model or session for a value which
// should provide a convenient method of re-populating the forms on post.
$selected = $this->getValueAttribute($name, $selected);
$options['id'] = $this->getIdAttribute($name, $options);
if (!isset($options['name'])) {
$options['name'] = $name;
}
// We will simply loop through the options and build an HTML value for each of
// them until we have an array of HTML declarations. Then we will join them
// all together into one single HTML element that can be put on the form.
$html = array();
foreach ($list as $value => $display) {
$html[] = $this->getSelectOption($display, $value, $selected);
}
// Once we have all of this HTML, we can join this into a single element after
// formatting the attributes into an HTML "attributes" string, then we will
// build out a final select statement, which will contain all the values.
$options = $this->html->attributes($options);
$list = implode('', $html);
return "<select{$options}>{$option}{$list}</select>";
});
作者:adhikjosh
项目:D-provide
/**
* 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');
}
}
}
作者:rtconne
项目:laravel-plusplu
public function button($value = null, $options = array())
{
if (strpos(@$options['class'], 'btn') === false) {
@($options['class'] .= ' btn btn-default');
}
return parent::password($value, $options);
}
作者:ruys
项目:laravel4-for
/**
* 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;
}
作者:ruys
项目:laravel4-for
/**
* 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;
}
作者:OmarMakle
项目:Htm
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());
}
作者:Javier-Rotell
项目:bootstrap-for
/**
* 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);
}
作者:shyam-achutha
项目:laravel5bootstrap3for
/**
* 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);
}
作者:iyowork
项目:form-builde
/**
* @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);
}
作者:kamarol
项目:shif
/**
* 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);
}
作者:janusni
项目:23copperlea
/**
* 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;
}
作者:illuminate
项目:bootawesom
/**
* 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;
}
作者:laravel-commod
项目:blade
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');
}
作者:sohailaammaroc
项目:lf
/**
* Prepare data grid columns.
*
* @param bool $results
* @return array
*/
protected function prepareColumns($model)
{
$el = [];
foreach ($this->dataGridColumns as $attributes) {
$type = array_pull($attributes, 'type');
if ($type) {
if ($type === 'a') {
$elementContent = '<%= r.' . array_pull($attributes, 'content') . ' %>';
$link = $this->html->decode($this->html->link('#', $elementContent, $attributes));
$link = str_replace('href="#"', 'href="<%= r.edit_uri %>"', $link);
$el[] = $link;
} elseif ($type === 'checkbox') {
$checkBoxName = array_pull($attributes, 'name');
$value = array_pull($attributes, 'value');
$value = '<%= r.' . $value . ' %>';
$el[] = $this->html->decode($this->form->checkbox($checkBoxName, $value, null, $attributes));
}
} else {
$el[] = '<%= r.' . array_pull($attributes, 'content') . ' %>';
}
}
return $el;
}
作者:jamalapriad
项目:si
/**
* 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())
{
$return = '';
$options = array_merge(array('class' => 'form-control', 'id' => $name), $options);
$containerAttributes = $this->getContainerAttributes($options);
$labelAttributes = $this->getLabelAttributes($options);
if (!isset($containerAttributes['display'])) {
$return .= $this->group($name, $errors, 'form-group', $containerAttributes);
}
$return .= $this->label($name, $label, $labelAttributes);
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";
}
if (!isset($containerAttributes['display'])) {
$return .= '</div>' . "\n";
}
return $return;
}
作者:ola
项目:epetition
/**
* Creates a color element
*
* @param string $name The name of the element
* @param null $value
* @param array $attributes
* @return string
*/
public function color($name, $value = null, $attributes = array())
{
$attributes['class'] = isset($attributes['class']) ? self::FORM_CONTROL . ' ' . $attributes['class'] : self::FORM_CONTROL;
return parent::input('color', $name, $value, $attributes);
}