Comments (3)
By default button type is using a label for name, so this is in template:
<?= Form::button($options['label'], $options['attr']) ?>
There are several solutions:
- Publish views and update button template to something like this:
<?php if ($options['default_value']): ?>
<?= Form::button($options['default_value'], $options['attr']) ?>
<?php else: ?>
<?= Form::button($options['label'], $options['attr']) ?>
<?php endif; ?>
- Create custom button type:
Template: fields.custom_button
<?= Form::button($options['default_value'], $options['attr']) ?>
Field Class:
use Kris\LaravelFormBuilder\Fields\FormField;
class CustomButton extends FormField {
public function getTemplate()
{
return 'fields.custom_button';
}
}
Form Class:
class MyForm extends Form
{
public function buildForm()
{
// This can be added also in published configuration in config/laravel-form-builder.php
$this->addCustomField('custom_button', 'App\Forms\Fields\CustomButton');
$this->add('buttons', 'collection', [
'type' => 'custom_button',
'property' => 'name' // This is pulled from model value , [ ['name' => 'button1'], ['name' => 'button2'])
]);
}
}
I would probably go with 1st solution because it's much simpler.
from laravel-form-builder.
Thank you, I knew that I should change template but not what parameter use as label.
Maybe you can set to documentation all standard variables available in templates? Probably it will be useful for more people.
from laravel-form-builder.
Yeah I planned to do that, just didn't have time. Will do it when i catch up.
from laravel-form-builder.
Related Issues (20)
- Remove laravelcollective/html HOT 11
- v1.50 breaks field type collection HOT 5
- BUG: radio buttons chioce type returns an array HOT 5
- Feature request: Switching between classes by theme HOT 9
- Please change CHANGELOG and Releases HOT 3
- Select option for null values HOT 3
- Multiple file upload HOT 1
- Feature request: Add conditional field HOT 3
- Add Fieldset type HOT 3
- Compatibility Laravel 9 ? HOT 2
- getFieldValues() default value instead of null HOT 2
- Default placeholder for entity type(Field::ENTITY). HOT 1
- Radio button has problem HOT 2
- Using entity how we can display format with multiple columns HOT 1
- Collection of templated form HOT 2
- Error: count(): Argument #1 ($value) must be of type Countable|array, Mekongdelta\Slug\Models\Slug given HOT 5
- Validate without request HOT 10
- Invalid pattern for input
- At least one "choice" checkboxes required HOT 2
- Support for Laravel 11 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-form-builder.