`crud.field()` js library bugs
See original GitHub issue@pxpm said (_Originally posted by @pxpm in https://github.com/Laravel-Backpack/CRUD/pull/4312#pullrequestreview-944434626_)
Hey @tabacitu amazing work here! So I am just giving this a round up review, I am not going to work on fixes unless you tell me to.
So until now I figured out that:
- It does not work with arrayed name fields like
date_range
. It will throw an error in wrapper because of thebp-field-name
Yeah, we SHOULD fix this.
- jquery
date_picker
anddatetime_picker
catch the change event when initializing, but then donβt catch the change when you select a date from the picker. (also happens with:address_algolia
fields)
Yeah, we MUST fix this.
- In the
date
html field, if you are manually typing the date, the change event is triggered in every keystoke when you start inputing the year. Same happens withdatetime, time, month, week
Iβm ok with thisβ¦ I donβt think we should do anything about this, itβs just the way these work. Wouldnβt you agree? Iβd say WONβT DO.
crud.field('date').onChange(function(e, value) {
console.log('date')
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var selectedDate = Date.parse(value);
if (selectedDate < today) {
new Noty({
type: "error",
text: "date cant be lower than today"
}).show();
}
});
- for hasOne with dot notation the
bp-field-name
should probably beaddress.street
so developer can target it withaddress.street
, otherwise it needs to know beforehand that we will change the name toaddress[street]
. At the moment trying to addaddress.street
as a field name in javascript will break the jquery search, changing to passing full strings to the search query makes it work:
Thanks, we COULD fix this.
constructor(fieldName) {
this.name = fieldName;
this.wrapper = $('[bp-field-name="'+ this.name +'"]');
this.input = $('[bp-field-main-input][name="'+ this.name +'"]');
// if no bp-field-main-input has been declared in the field itself,
// assume it's the first input in that wrapper, whatever it is
if (this.input.length == 0) {
this.input = $('[bp-field-name="'+ this.name +'"] input, [bp-field-name="'+ this.name +'"] textarea, [bp-field-name="'+ this.name +'"] select').first();
}
this.value = this.input.val();
}
- The multiple selects use an hidden input with empty value, not to store the field itself but to submit when nothing is selected. I could not target the selects with
name
orname[]
. I tried to add:
'wrapper' => [
'class' => 'form-group col-md-6',
'bp-field-main-input' => 'name[]'
],
No avail here.
Great catch! We MUST fix this.
- canβt make any js editor work with onChange, neither by typing or moving focus out.
Another great catch, we MUST fix this.
- video field does not catch the event too.
SHOULD DO.
color_picker
jquery plugin will trigger the change event when you drag to chose the color triggering hundreds of times in a short period.
π€·ββοΈ Iβm ok with itβ¦ to be honestβ¦ Iβd say WONβT DO.
icon_picker
does not work too
SHOULD DO
- I havenβt tried this with repeatable, but we should consider the βevents/hooksβ aproach for table as this script has no effect on table field.
COULD DO
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
set_field_upload Problem on edit - Bugs / Issues
I have this code: public function editar_solicitud_red($state = NULL, $codigo) {; $crud = new grocery_CRUD();Β ...
Read more >CrudField JavaScript Library :: 5.x Docs - Backpack for Laravel
selected a field using crud.field('agree_to_terms') ;; defined what happens when that field gets changed, using .onChange() ;; triggered the change event usingΒ ...
Read more >Version and Feature Details of PDO CRUD
BugFixed: Fixed a small bug related to email with insert data and related data. Version 4.0 β (Changes in template file, config file...
Read more >[Solved]-Trouble in search in Grocery CRUD library-codeigniter
This is likely a bug of grocery crud, interpreting 0 as null so it does not apply the search filter. I suggest filling...
Read more >CRUD with React and GraphQL: A complete tutorial with ...
Reading and writing data with GraphQL; CRUD in React using graphql-client. What is React? React is a JavaScript library forΒ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pxpm letβs centralize our testing in this table, using this demo branch. Legend:
onChange()
hide()
show()
enable()
disable()
require()
unrequire()
check()
, βuncheck()
@tabacitu from my last tests (with pending prβs merged) itβs only missing:
repeatableenumaddress_googlechecklist_dependencydate_range