laravelcollective / html Goto Github PK
View Code? Open in Web Editor NEWHTML and Form Builders for the Laravel Framework
License: MIT License
HTML and Form Builders for the Laravel Framework
License: MIT License
Hi, maybe i'm doing something wrong, but after update to 5.1.6 (from 5.1.4) checkbox will not be checked if model value is '1'...
Form::model($mymodel ...)
Form::checkbox('field','1',false)
any other way to set checbox to checked if value is ==1 ?
tnx
laravel 5 it start to showing blank white page after adding 'Collective\Html\HtmlServiceProvider' in provider and 'Form' => 'Collective\Html\FormFacade','Html' => 'Collective\Html\HtmlFacade' for using form tag,I have update the composer successfully .Im working linux (mint).Thanks in advance.
When null is being passed as the value to Form::date() to allow form-model binding to automatically set it, it's not being formatted into Y-m-d as it would be if the value were to be input manually. Instead it's the full DateTime string.
Form::model() // edit.blade.php
Form::date('started_at', $model->started_at, $options) //_form.blade.php
// returns properly
Form::model() // edit.blade.php
Form::date('started_at', null, $options) // _form.blade.php
// returns full DateTime and doesn't get treated properly by the browser
Form::open() // create.blade.php
Form::date('started_at', $model->started_at, $options) // _form.blade.php
// throws an exception, as $model doesn't exist yet
Form::open() // create.blade.php
Form::date('started_at', null, $options) // _form.blade.php
// treated properly by browser
I'm using the FormBuilder and have a select named the same thing as one of my model's relationships (a many-to-many relationship), but when using form model binding, it ignores any attempts I make to manually override the status of whether it's selected or not.
{!! Form::select('usergroups[]', $groups, $user->groups->lists('id'), array('multiple' => 'multiple') !!}
Doing this, I would expect it a select with some selected values, depending my relationship piece. Instead, no select is selected.
This is User model relationship:
public function groups()
{
return $this->belongsToMany('SSHAM\Usergroup');
}
And this my controller wich calls the view:
public function edit(User $user)
{
// Get all existing user groups
$groups = Usergroup::lists('name', 'id');
return view('user.edit', compact('user', 'groups'));
}
And my view:
{!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'put']) !!}
{!! Form::select('usergroups[]', $groups, $user->groups->lists('id'), array('multiple' => 'multiple') !!}
{!! Form::close() !!}
Am I missing something about how to get this to work or have I stumbled across an issue?
Form::radio('foo', '1');
Form::radio('foo', '2');
Html =>
<input name="foo" type="radio" value='1" id="foo">
<input name="foo" type="radio" value='2" id="foo">
Why must add an "id"? In addition, the "id" must be unique…
How to use trans() function with Forms?
When using Eloquent Attribute casting for an array the checkbox is not able to retrieve the model value. It thinks the model is an object but the accessed attribute is an array, that leads to the object_get method returning null. A possible quickfix is converting every model to an array.
/**
* Create a new model based form builder.
*
* @param mixed $model
* @param array $options
* @return string
*/
public function model($model, array $options = array())
{
$this->model = $model->toArray();
return $this->open($options);
}
Maybe someone can come up with a better way to manage that.
if not set a value attribute then submit a inner tag.
< return '<option' . $this->html->attributes($options) . '>' . e($display) . '</option>';
---
> return '<option' . $this->html->attributes($options) . ' value="">' . e($display) . '</option>';
In the "Labels" section there is reference to how to create additional HTML attributes.
In the Drop-down-lists section it would be clearer to mention that there must be a default value before an array for HTML attributes (even if null).
i.e. echo Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S');
Sorry for my english, I hope you will understand :)
Exact issue:
I named a field in database as "visible".
Eloquent model has a protected attribute with same name: protected $visible = [];
When form builder tries to get this field value from model instance, it returns this protected attribute, instead of the data field.
protected function getModelValueAttribute($name)
{
if ($name=='visible') dd(data_get($this->model, $this->transformKey($name))); // returns array(0) instead of "1" or "0".
return data_get($this->model, $this->transformKey($name));
}
It's because the core eloquent model has ArrayAccess interface.
The data_get helper function runs into this case:
......
} elseif ($target instanceof ArrayAccess) {
[DEBUG HERE]
if (! isset($target[$segment])) {
return value($default);
}
....
DEBUG:
d($target['visible']) => array(0)
d($target->visible) => 1 (correct database value)
When I dump entire $target, the model instance is fine, and the visible attribute too.
Probably would be the same with guarded, fillable, etc fields.
method call: {!! Form::radio('visible', 1) !!}
Maybe this was the same issue: #64
Thanks
Let's say i've got a route definition:
Route::put('users/{user_id}/update', ['as' => 'users.update']);
In order to make a form that submits to that route, i have to do:
echo Form::open(['route' => ['users.update', $user->id], 'method' => 'put']);
It seems strange having to specify the http method in Form::open
, when the route definition already has that information. The same is true of controller actions - they both refer to a route definition that has method and url information.
It would be nice to just be able to give the route name:
echo Form::open(['route' => ['users.update', $user->id]]);
With regards to implementation, I've got an idea - i'll PR it.
As far as i understood {{ }} == echo
, but when using it with a Form::select
in Laravel 5 it just doesn't work, it prints to screen the html code, but when using <?php echo Form::select ... ?>
Before this, I used laravel illuminate/html with the Html::image() tag and it worked fine. This package doesn't seem to support the Html::image() because when I try to use Html::image(), the view return an error and complains that: 'Class 'HTML' not found'
I can use Form::image() with LaravelCollective/html and it works perfetcly but, Form::image() is not what I want because it generates form input instead of a displaying a normal image on the view. For example:
{!! Form::image('image/icons/like.png','success', array( 'width' => 32, 'height' => 32 )) !!}
is actually this:
<input width="32" height="32" src="http://testdomain.com/images/icons/like.png" name="success" type="image">
Of course the disadvantage is that you will have a clickable icon on the image.
I have declared the following allias in the app.php
'Html' => Collective\Html\HtmlFacade::class,
It seems like there is no example either in the documentation how to use Html::image(). Does it exist? Should I install illuminate/html and remove the laravelcollective html facade? Please suggest, not sure if this is just a bug.
Hello, I've used
Form::text($name, $value, $attributes);
may it switch to ?
Form::text($name, $attributes, $value);
I think I alway use class
or id
and placeholder
$attributes
more than the $value
,
Because people usually use Form::model
and when they used Form::model
and want to use $attributes
they alway do the long string of this.
{!! Form::text('name', isset($category->name) ? $category->name : '', ['class' => 'someclass' , 'id' => 'name']) !!}
But if we switch to
they will be use like this
if they don't want value
{!! Form::text('name', ['class' => 'someclass' , 'id' => 'name']) !!}
// if they want value
{!! Form::text('name', [], 'somevalue') !!}
or
{!! Form::text('name', ['class' => 'someclass' , 'id' => 'name'], 'somevalue') !!}
It will be shorten than the first one right ?
Best regards.
Hello, i'm using FormBuilder to add a couple of select elements
This select fields are tied to a model relation.
Currently i workaround this with a custom attribute to retrieve the selected elements from the relation and converting them to an array so https://github.com/LaravelCollective/html/blob/5.1/src/FormBuilder.php#L660 can read this options.
I'm thinking of adding a pull request for this to be taken care on the same method to allow for collections to be interpreted directly on the model.
IE.
if(is_array($selected))
{
return in_array($value, $selected) ? 'selected' : null;
}
elseif($selected instanceof Collection)
{
return $selected->contains('id', $value) ? 'selected' : null;
}
The problem is that a many-to-many relation should be indexed by the 'id' field following laravel convention, but might be a case where the id actually calls ie. "company_id", in this case the 'id' field would be hardcoded on the condition.
My final issue is should i add this pull request or this should be handled by developers on their own models or views? Is this an issue to someone else or does this have enough support?
Thanks
I need to create link which will contain not only plain text, but icon in addition, what is a best approach to make it?
{!! link_to('/home', '<i class="fa fa-home"></i> Main page') !!}
Using this way symbols <
and >
decoded and icon isn't displaying because of it.
Thanks.
I have posted the problem here
http://stackoverflow.com/questions/30892701/laravel-5-1-form-and-html-faced-problems
Under Forms and HTML, in the documentation (readme) for this section, there's no mention of the HTML helpers that the package supports. Or I missed something.
It's expected to implement HTML::ul, like in Laravel 4?
Using Laravel 5.0 with this library used to work fine, but now since I had to upgrade to Laravel 5.1, the library seems to be malfunctioning. I've also installed the 5.1 version of this html/form library too.
Here's how to replicate this:
{!! Form:open([ url => 'foo/bar' ]) !!}
{!! Form:close !!}
<form method="POST" action="">
Looking at the code, I did see it could possibly have been renamed to 'action' from 'url', but trying that does nothing different. The forms just want to post back to the route they were called from.
A timely resolution would be appreciated.
Sometimes HTML anchor title contains html tags and link method remove them
https://github.com/LaravelCollective/html/blob/5.0/src/HtmlBuilder.php#L134
{!! link_to_route('users.index', 'Users') !!}
Is resulting in
url.com/users?
There should be no extra question mark at the end of the URL
When having a value defined in old input it will take precedence over default value, sounds logical.
But when having a value defined in the model, default value will take precedence over model value, I don't understand that, isn't default value intended to be used when there is no other value available ? (in the model or the old input)
Why do default value is prefered to model value ?
Did i do something the wrong way ? ("1" is the default value here) :
{!! Form::number('field_name', 1, ['class' => 'form-control']) !!}
I fix'd it this way, but that's ugly, I must had misunderstood something :
{!! Form::number('field_name', (!empty($model) && $model->field_name !== null)?$model->field_name:1, ['class' => 'form-control']) !!}
{!! Form::hidden($param->ip_id, @{{ angularModel }}) !!}
this will not work. How do I do that for Angular?
Hi there,
I maintain Bootstrapper and someone's recently raised patricktalmadge/bootstrapper#279 which leads to our code conflicting since we typehint the Illuminate version of the components. We're still supporting Laravel 4 for a few more months (probably waiting until Twitter Bootstrap v4.0.0 and/or our cross framework project is completed).
Would it be possible for you to add an extra binding (say, collective::html
) so that we can use the Laravel 5 version in the meantime? I'm happy to do some real work on compatibility fixing our code if there are issues in illuminate/html
that are resolved in this fork that I'm unaware of but I'd like to avoid it if I can
In the below I would expect it to select the Any
option but instead it selects the Closed
one.
{!! Form::model(['status' => '']) !!}
{!! Form::radio('status', '') !!} Any
{!! Form::radio('status', 'Open') !!} Open
{!! Form::radio('status', 'Closed') !!} Closed
{!! Form::close() !!}
This is due to a non strict type check on https://github.com/LaravelCollective/html/blob/5.1/src/FormBuilder.php#L792
It's essentially doing '' == 0
which returns true, so selects the 'Closed' option.
Do you think empty strings should be handled explicitly?
I am using laravelcollective/html as a dependency (through composer.json), but applying newest tests (current tests/FormBuilderTests.php) - and one test fails to pass (testFormRepopulationWithMixOfArraysAndObjects).
Current implementation of FormBuilder::getModelValueAttribute fixes it, while implementation of latest tagged version (5.0.4) fails to pass.
Can you please add a new version tag (5.0.5) so I can have a tests-proof version using composer?
Thank you.
Hi,
I made a fresh laravel 5.1+ installtion via laravel new
and did the steps required for this package (composer, providers, aliases).
=>
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Collective\Html\HtmlServiceProvider' not found
Composer require section:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "5.1.*"
},
Any guesses?
Hi,
I'm getting the following exception when I try to use the Form::number()
method:
exception 'BadMethodCallException' with message 'Method number does not exist.'
in vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:87
Although the documentation mentions this method, I couldn't find the implementation in the source.
{!! Form::button('<i class="fa fa-plus"></i> '.Lang::get('location.button_create'), array('class' => 'btn btn-primary')) !!}
^^ OK!
{!! Form::submit('<i class="fa fa-plus"></i> '.Lang::get('location.button_create'), array('class' => 'btn btn-primary')) !!}
^^ doesn't work.
The only difference is the submit v.s. button. Is this a bug? Or am I missing something?
Hello
I'm trying to deploy my laravel project to heroku. Application works fine locally, but when I try to deploy it on heroku i get the following error:
Writing objects: 100% (9/9), 1.01 KiB | 0 bytes/s, done.
Total 9 (delta 6), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching custom git buildpack... done
remote: -----> PHP app detected
remote: -----> Resolved composer.lock requirement for PHP to version 5.6.10.
remote: -----> Installing system packages...
remote: - PHP 5.6.10
remote: - Apache 2.4.10
remote: - Nginx 1.6.0
remote: -----> Installing PHP extensions...
remote: - mbstring (composer.lock; bundled)
remote: - zend-opcache (automatic; bundled)
remote: -----> Installing dependencies...
remote: Composer version 1.0.0-alpha10 2015-04-14 21:18:51
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
remote: - Installing jakub-onderka/php-console-color (0.1)
remote: Downloading: 100%
remote:
remote: - Installing vlucas/phpdotenv (v1.1.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/var-dumper (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/translation (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/routing (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/process (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/http-foundation (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/event-dispatcher (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing psr/log (1.0.0)
remote: Downloading: 100%
remote:
remote: - Installing symfony/debug (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/http-kernel (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/finder (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/dom-crawler (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/css-selector (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing symfony/console (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing swiftmailer/swiftmailer (v5.4.1)
remote: Downloading: 100%
remote:
remote: - Installing nikic/php-parser (v1.3.0)
remote: Downloading: 100%
remote:
remote: - Installing jakub-onderka/php-console-highlighter (v0.3.2)
remote: Downloading: 100%
remote:
remote: - Installing dnoegel/php-xdg-base-dir (0.1)
remote: Downloading: 100%
remote:
remote: - Installing psy/psysh (v0.4.4)
remote: Downloading: 100%
remote:
remote: - Installing nesbot/carbon (1.20.0)
remote: Downloading: 100%
remote:
remote: - Installing mtdowling/cron-expression (v1.0.4)
remote: Downloading: 100%
remote:
remote: - Installing monolog/monolog (1.14.0)
remote: Downloading: 100%
remote:
remote: - Installing league/flysystem (1.0.4)
remote: Downloading: 100%
remote:
remote: - Installing jeremeamia/superclosure (2.1.0)
remote: Downloading: 100%
remote:
remote: - Installing doctrine/inflector (v1.0.1)
remote: Downloading: 100%
remote:
remote: - Installing danielstjules/stringy (1.9.0)
remote: Downloading: 100%
remote:
remote: - Installing symfony/filesystem (v2.7.1)
remote: Downloading: 100%
remote:
remote: - Installing classpreloader/classpreloader (1.4.0)
remote: Downloading: 100%
remote:
remote: - Installing laravel/framework (v5.1.3)
remote: Downloading: 100%
remote:
remote: Generating optimized autoload files
remote: PHP Fatal error: Class 'Collective\Html\HtmlServiceProvider' not found in /tmp/build_44f0e34f5ede5fd47193377db8b28292/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
remote:
remote:
remote:
remote: [Symfony\Component\Debug\Exception\FatalErrorException]
remote: Class 'Collective\Html\HtmlServiceProvider' not found
remote:
remote:
remote:
remote: Script php artisan clear-compiled handling the post-install-cmd event returned with an error
remote:
remote:
remote:
remote: [RuntimeException]
remote: Error Output: PHP Fatal error: Class 'Collective\Html\HtmlServiceProvider' not found in /tmp/build_44f0e34f5ede5fd47193377db8b28292/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
remote:
remote:
remote:
remote: install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]
remote:
remote:
remote:
remote: ! Push rejected, failed to compile PHP app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to alican.
remote:
Please see PR here: laravel/framework#7965 (comment)
The fix is to make an update to the __call method on HTML/Form and if said method returns a RenderableInterface, then to call render on the returned view.
I want to send multiple values to my controller, but when I use:
{!! Form::select('course_phases[]', $phases, null, ['class' => 'form-control', 'multiple']); !!}
or
{!! Form::text('course_phases[]', null, ['class' => 'form-control', 'multiple']); !!}
I'm getting this exception
htmlentities() expects parameter 1 to be string, array given (View:[path])
Then I switched to illuminate/html with no changes on my view and works fine, what I'm doing wrong with this package?
EDIT: Forget it, my problem was a javascript outside my form with an input text embbeded, don't know yet how happened!
It seems you cannot do the following..
{!! Form::model($model, ['route' => ['my.named.route', [$id, $other]]]) !!}
..but sometimes you need to pass in more than one parameter to the named route, even if it's just GET variables
I think that, it is good it add other UI like datepicker, select2...?
Hello team,
I'm having an issue with Form::select as no placeholder is displayed while it is correctly set up in my blade (exactly copy-pasted from 5.1 doc). Does anyone encounter this problem?
Below a piece of code of my blade + my app configuration and my composer installed components:
I am using Laravel 5.1.
Form blade:
{!! Form::model($advert, ['route' => ['cms.adverts.update', $advert->id], 'method' => 'put', 'class' => 'form-horizontal panel', 'files' => true]) !!}
{!! Form::submit('Edit', ['class' => 'btn btn-primary pull-right']) !!}
{!! Form::close() !!}
Config:
env('APP_DEBUG', true), 'url' => 'http://localhost', 'timezone' => 'Europe/Rome', 'locale' => 'it', 'fallback_locale' => 'en', 'key' => env('APP_KEY', 'fooKey'), 'cipher' => 'fooCypher', 'log' => 'single', 'providers' => [ Illuminate\Foundation\Providers\ArtisanServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Routing\ControllerServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, App\Providers\AppServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, Collective\Html\HtmlServiceProvider::class, Intervention\Image\ImageServiceProvider::class, ], 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Form' => Collective\Html\FormFacade::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Html' => Collective\Html\HtmlFacade::class, 'Image' => Intervention\Image\Facades\Image::class, 'Input' => Illuminate\Support\Facades\Input::class, 'Inspiring' => Illuminate\Foundation\Inspiring::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, ], ]; Output from composer show --installed: classpreloader/classpreloader 2.0.0 Helps class loading performanc... danielstjules/stringy 1.9.0 A string manipulation library ... dnoegel/php-xdg-base-dir 0.1 implementation of xdg base dir... doctrine/inflector v1.0.1 Common String Manipulations wi... doctrine/instantiator 1.0.5 A small, lightweight utility t... fzaninotto/faker v1.5.0 Faker is a PHP library that ge... guzzlehttp/psr7 1.1.0 PSR-7 message implementation hamcrest/hamcrest-php v1.2.2 This is the PHP port of Hamcre... intervention/image 2.3.1 Image handling and manipulatio... jakub-onderka/php-console-color 0.1 jakub-onderka/php-console-highlighter v0.3.2 jeremeamia/SuperClosure 2.1.0 Serialize Closure objects, inc... laravel/framework v5.1.7 The Laravel Framework. laravelcollective/html v5.1.2 league/flysystem 1.0.9 Filesystem abstraction: Many f... mockery/mockery 0.9.4 Mockery is a simple yet flexib... monolog/monolog 1.15.0 Sends your logs to files, sock... mtdowling/cron-expression v1.0.4 CRON for PHP: Calculate the ne... nesbot/carbon 1.20.0 A simple API extension for Dat... nikic/php-parser v1.4.0 A PHP parser written in PHP phpdocumentor/reflection-docblock 2.0.4 phpspec/php-diff v1.0.2 A comprehensive library for ge... phpspec/phpspec 2.2.1 Specification-oriented BDD fra... phpspec/prophecy v1.4.1 Highly opinionated mocking fra... phpunit/php-code-coverage 2.1.8 Library that provides collecti... phpunit/php-file-iterator 1.4.0 FilterIterator implementation ... phpunit/php-text-template 1.2.1 Simple template engine. phpunit/php-timer 1.0.6 Utility class for timing phpunit/php-token-stream 1.4.3 Wrapper around PHP's tokenizer... phpunit/phpunit 4.7.7 The PHP Unit Testing framework. phpunit/phpunit-mock-objects 2.3.5 Mock Object library for PHPUnit psr/http-message 1.0 Common interface for HTTP mess... psr/log 1.0.0 Common interface for logging l... psy/psysh v0.5.2 An interactive shell for moder... sebastian/comparator 1.1.1 Provides the functionality to ... sebastian/diff 1.3.0 Diff implementation sebastian/environment 1.2.2 Provides functionality to hand... sebastian/exporter 1.2.0 Provides the functionality to ... sebastian/global-state 1.0.0 Snapshotting of global state sebastian/recursion-context 1.0.0 Provides functionality to recu... sebastian/version 1.0.6 Library that helps with managi... swiftmailer/swiftmailer v5.4.1 Swiftmailer, free feature-rich... symfony/console v2.7.2 Symfony Console Component symfony/css-selector v2.7.2 Symfony CssSelector Component symfony/debug v2.7.2 Symfony Debug Component symfony/dom-crawler v2.7.2 Symfony DomCrawler Component symfony/event-dispatcher v2.7.2 Symfony EventDispatcher Component symfony/finder v2.7.2 Symfony Finder Component symfony/http-foundation v2.7.2 Symfony HttpFoundation Component symfony/http-kernel v2.7.2 Symfony HttpKernel Component symfony/process v2.7.2 Symfony Process Component symfony/routing v2.7.2 Symfony Routing Component symfony/translation v2.7.2 Symfony Translation Component symfony/var-dumper v2.7.2 Symfony mechanism for explorin... symfony/yaml v2.7.2 Symfony Yaml Component vlucas/phpdotenv v1.1.1 Loads environment variables fr... Extract from my composer.json: ....... "require": { "php": ">=5.5.9", "laravel/framework": "5.1._", "laravelcollective/html": "5.1._", "intervention/image": "^2.3" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~4.0", "phpspec/phpspec": "~2.1" }, ....... Can someone help me or indicate me what I am doing wrong? Thanks for your help in advance, CDFContinuing from this discussion, I believe it would be worthwhile to have an easier way to include an empty top option in a select field. It can be a pain to have to prepend it to a Collection
manually (figuring out how to preserve keys) before passing it to Form::select
, while I do believe this is a common use-case. Many dropdowns do not have anything selected by default, after all, so it would be nice if there were no hurdles to overcome to get this functionality.
What could be the best way to fix this? If not through a new option on Form::select
, perhaps with a new built-in macro?
Currently, if you pass in a numerical-keyed attribute, it will assume the key and value are the same. For example:
echo Form::select('choices', $choices, [ 'class' => 'foo', 'multiple' , 'required'] );
This will render with overly verbose attributes which are redundant, especially especially in HTML5.
<select name="choices" id="choices" class="foo" multiple="multiple" required="required">
...
</select>
Could the HtmlBuilder::attributeElement() method be modified so that numerically-keyed attributes just return a minimized (i.e. value-less) attribute? Maybe something like:
protected function attributeElement($key, $value)
{
// For numeric keys we will assume that the value is the key and the attribute is
// to be minimized. This will render attributes like "required" or "multiple" correctly,
// instead of using numerics.
if (is_numeric($key)) return $value;
if ( ! is_null($value)) return $key.'="'.e($value).'"';
}
This would then render as the smaller (and still valid):
<select name="choices" id="choices" class="foo" multiple required>
...
</select>
When I hava a table with two columns active
tinyint(1) and visible
tinyint(1) and try to populate a form with model binding the active
field displays correctly and the visible
field stays empty.
When I changed out {!! Form::checkbox('visible', true) !!}
for {!! Form::text('visible'']) !!}
I get an error:ErrorException in helpers.php line 454: htmlentities() expects parameter 1 to be string, array given
formed in: HtmlBuilder->attributes(array('class' => 'form-control', 'required', 'name' => 'visible', 'type' => 'text', 'value' => array(), 'id' => null)) in FormBuilder.php line 248
I think it might use the protected property of the Eloquent Model?
The workaround I used for now was to cast the Eloquent result to an array and then back to an object:
$user = $User::find(1);
$user = (object) $user->toArray();
This package can also be compatible with Lumen framework.
What I did to make it work:
Seems to work fine.
It would be great to have compatibility with Lumen out of the box!
Hi,
I'm using date mutators in a model passed to Form::model(). Unfortunately the date is not formatted to the Y-m-d form, because the formatting is performed only on the DateTime object passed directly to the date() function. Maybe this code should be placed in the getValueAttribute() function with additional check on the field type? Or there is a better place?
HOW TO REPRODUCE BUG:
I have an m:m relation in my isolated form.
This relation si rendered by a list of checkboxes.
Checkboxes names are in the form form_name[relation_name][]
BUG:
Form checkboxes autofill functionalities works well only when:
ERROR:
On edit form data the autofill functionalities wont' work because $posted is a Collection.
While updating composer it shows Call to undefined method Illuminate\Foundat
ion\Application::getCachedCompilePath() in /var/www/laravel-project/vendor/
laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.ph
p on line 28 .Working on linux fresh install .
I'm using the FormBuilder and have a checkbox named the same thing as one of my model's relationships (a many-to-many relationship), but when using form model binding, it ignores any attempts I make to manually override the status of whether it's checked or not.
{!! Form::checkbox('tags[]', $id, (in_array($id, $articleTags)) !!} {{ $tag }}
Doing this, I would expect it to ignore the relationship piece (which is tries to handle, albeit unsuccessfully, behind the scenes) and instead, use the logic I put in there. Instead, every checkbox is checked, even if I put false
in the third parameter.
Am I missing something about how to get this to work or have I stumbled across an issue?
Hello, I'm trying to use autofocus
with partial form.
Did I do the right thing ? Or it has an easy way to do this ?
{!! Form::text('firstname', isset($user->firstname) ? $user->firstname : '', ['autofocus' => '']) !!}
Thanks.
--- Edit ---
I added js to autofocus end of the text.
{!! Form::text('tax', isset($config->tax) ? $config->tax : '', ['autofocus' => '', 'onfocus' => 'this.value = this.value;']) !!}
The following doesn't work: (text field has not TEST value)
{!! Form::model($page, array('method'=>'PATCH', 'files'=>true, 'route' => array( 'admin.pages.update', $page->id ) )) !!}
{!! Form::text('parent_text','TEST',array('class'=>'form-control parent')) !!}
{!! Form::close() !!}
Seems that second field parameter is ignored if old input is present. Weird behaviour as in L4 you could keep old input passing null, or overwrite it passing a value.
There is no code formatting convention in this packages. This is a real issue because it complicates merges (I experienced that this morning), it produces useless diffs (see this one : 9c4fea1) and it gives a bad example to newcomers about our quality standards.
There are files indented with 2 spaces, 4 spaces or tabs. Sometimes a mix of two of this options.
I suggest to use the Laravel 5.1 convention : PSR-2. At least, the indentation should be harmonized ! I think that this should be done in 5.1 and master branches (they are very close).
I can do it if you have not time for that but I wait for your go for now.
If I have the route:
Route::put('cart/add', ['as' => 'cart.add', 'uses' => 'CartController@addProduct']);
and in a view I have:
{!! Form::open(['route' => 'cart.add']) !!}
I expect the output:
<form method="POST" action="http://localhost:8000/cart/add" accept-charset="UTF-8">
<input name="_method" type="hidden" value="PUT">
<input name="_token" type="hidden" value="wL3...">
But it does not create the _method
hidden field. It should detect that the route is a PUT, and automatically output the _method
hidden field.
This should work for every non-POST route: GET, PUT, PATCH, DELETE.
Backwards compatibility shouldn't be an issue, as if people have named routes that aren't POST they're already creating their own _method
field which will override the one Form::open would create.
Is this something that would be accepted as a pull request?
Hi,
We know Laravel 5.1 has not been released yet. But, is there way to install this package in laravel 5.1 (dev-develop version). Or can you create a new branch for Laravel 5.1?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.