Comments (6)
I try to looking in custom-bindings.js but not found anything about enum yet, is that mean we must write new rule for this enhancement?
from laravel-administrator.
Good suggestion! I've implemented this for 2.2.0. If you're curious how it was done, check this out:
Basically, I had to adjust the Enum constructor to check for both array possibilities. So consider this example:
array(
'Winter' => 'Cold, Cold Winter!!',
'Spring',
'Summer' => 'Hot, Hot Summer',
'Fall'
)
In this case, the $options property in the Enum class would end up with this value:
array(
'Winter' => 'Cold, Cold Winter!!',
'Spring' => 'Spring',
'Summer' => 'Hot, Hot Summer',
'Fall' => 'Fall'
)
Then I had to adjust the filter and edit fields to include the optionsValue and optionsText properties of the Knockout options binding.
Custom bindings are only needed for special fields that can't be handled by existing bindings. As you can see, the enum field uses the custom chosen binding which turns the field into a jQuery Chosen object, so we don't need to do anything there. We need to handle that in a binding because Knockout refreshes the DOM whenever a viewModel observable updates.
from laravel-administrator.
Wow! Thanks
from laravel-administrator.
I store 0,1, 2 for user_role in my database and I can't use enum for this field. this is a little bit hack for my ugly DB structure. I changed enum.php line 32
from 'value' => is_numeric($val) ? $text : $val,
to 'value' => is_int($val) ? $text : $val,
and now I can used
'options' => array(
'00' => 'User',
'01' => 'Normal Curator',
'02' => 'Fetured Curator'
),
@janhartigan may you change is_numeric
to is_int
for more flexibility like this case
or any idea for better solution :)
from laravel-administrator.
Update: my solution is work grate in filters but doesn't work in edit, any idea? (T T)
from laravel-administrator.
OK so the issue here is that you shouldn't be using the enum field as you are. Enums are for text-only fields that don't have an ID. I assume you have a roles table, correct? So why not make a roles relationship and set up a relationship field?
from laravel-administrator.
Related Issues (20)
- how to upload mp3 file and get its duration in laravel 4.2 HOT 1
- add persian (farsi) language
- Domain HOT 3
- WYSIWYG: disable remove class
- Laravel 5.3 Mysql Strict Compatibly Issue HOT 2
- Frozennode.com HOT 10
- edit_fields in type "relationship" doesn't work when foreign key is a non-primary key.
- Response::download not work in global action HOT 1
- error "MethodNotAllowedHttpException in RouteCollection.php line 218:" on laravel 5.3
- Add field type "array"
- How to change column value depending on selection of other field using relationship field
- Trying to change the value of uri in administartor.php returns InvalidArgumentException in UrlGenerator.php line 307: Route [admin_dashboard] not defined. HOT 2
- documentation HOT 1
- Laravel 5.4 support HOT 6
- File Download Dialog does not trigger in Chrome 57 HOT 4
- Master / Child form
- Pulling out of this project HOT 1
- can't register provider in config/app.php
- ERROR: Function name must be a string
- PHP 7.2.4 sizeof(): Parameter must be an array or an object that implements Countable HOT 2
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-administrator.