kristijanhusak / laravel4-form-builder Goto Github PK
View Code? Open in Web Editor NEWLaravel Form builder for version 4!
Home Page: https://packagist.org/packages/kris/laravel4-form-builder
License: MIT License
Laravel Form builder for version 4!
Home Page: https://packagist.org/packages/kris/laravel4-form-builder
License: MIT License
Essential form:
$child = Form::create(...);
$child->remove('removed_field');
$parent = Form::create(...);
$parent->add('child', 'form', [ 'class' => $child ]);
form($parent); // yields a form containing removed_field
Looks like ChildFormType::createChildren() line 27 in the rebuildForm()
call is adding the fields back based on the original form specification. The docs do seem to be "class" oriented, but as objects are accepted, I'm expecting the object state to remain.
Hello everyone, I'm trying to put a multiple file upload system on laravel using the collections on FormBuilder, the added part works without problem but it's on the editing part that me block, I want that when editing files in each input also display, how to do? thank you very much.
Here is my exemple of add files
Essential example:
class MyForm extends Form {
public function buildForm() {
$this->add('foo', 'text');
$this->add('bar', 'repeated', [ 'type' => 'text', 'first_name' => 'bar', 'second_name' => 'bar_confirm' ]);
}
}
$child = new MyForm();
$parent = Form::create(...);
$parent->add('child', 'form', [ 'class' => $child ]);
The essential rendered output is:
<input class="form-control" id="foo" name="parent[foo]" type="text">
<input class="form-control" id="bar" name="bar" type="text">
<input class="form-control" id="bar_confirm" name="bar_confirm" type="text">
Expecting all inputs to be named in "parent" space, ie: parent[bar]
and parent[bar_confirm]
.
Is possible to inherit parents prototype name into childrens prototype in multiple nested form collections?
If I have users with multiple addresses, and address can have multiple cars. Car form prototype looks like this:
<div class="form-group" >
<label for="addresses[0][cars][__NAME__][brand]" class="control-label" for="timezone">Brand</label>
<input class="form-control" name="addresses[0][cars][__NAME__][brand]" type="text" id="addresses[0][cars][__NAME__][brand]">
</div>
This would be better this way:
<div class="form-group" >
<label for="addresses[__ADDRESS_NAME__][cars][__CAR_NAME__][brand]" class="control-label" for="timezone">Brand</label>
<input class="form-control" name="addresses[__ADDRESS_NAME__][cars][__CAR_NAME__][brand]" type="text" id="addresses[__ADDRESS_NAME__][cars][__CAR_NAME__][brand]">
</div>
see title
I have some custom fields and everything is fine when these fields are in level 1 hierarchy.
But if I put custom fields to a nested form (for example in a 'form' type) it renders as text.
I've noticed that the error messages in templates call ->first()
, but I think a more generic approach using ->all()
would support broader use. For example:
@if ($errors->has())
<div class='errors'>
@foreach ($errors->all() as $error)
<div class='error'>{{ $error }}</div>
@endforeach
</div>
@endif
Consider password validation. When a password fails to satisfy policy, there may be multiple messages, like "Password must contain at least one number" and "Password must contain at least one letter". All of these should be shown.
This can be solved by imploding all messages into the first. (What I'm doing now, actually.) Alternatively, this could be handled with custom templates. Both of these feel like hacks, though.
When you using collections in your form and you got error for a collection element, errors bag looks like this:
object(Illuminate\Support\ViewErrorBag)[125]
protected 'bags' =>
array (size=1)
'default' =>
object(Illuminate\Support\MessageBag)[126]
protected 'messages' =>
array (size=1)
'maximum' =>
array (size=1)
0 => string 'The maximum must be a number.' (length=29)
protected 'format' => string ':message' (length=8)
In this example there is a recipient collection which has minimum and maximum fields. Now I typed string into the second collection elements maximum field, but the error 'Max must be a number' will show for every maximum fields in this collection.
I have my User model mapped to a form.
Users can have multiple addresses (Address model).
There is one to many relationship between them.
For example if my user have 3 addresses, form will display the 3rd element 3 times.
I would like to add prototype-s to a data attribute in all collection view.
Is this possible to access prototype string in views/collection.php?
See title
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.