question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`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:

  1. It does not work with arrayed name fields like date_range. It will throw an error in wrapper because of the bp-field-name

Yeah, we SHOULD fix this.

  1. jquery date_picker and datetime_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.

  1. 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 with datetime, 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();
    }
});
  1. for hasOne with dot notation the bp-field-name should probably be address.street so developer can target it with address.street, otherwise it needs to know beforehand that we will change the name to address[street]. At the moment trying to add address.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();
        }
  1. 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 or name[]. 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.

  1. can’t make any js editor work with onChange, neither by typing or moving focus out.

Another great catch, we MUST fix this.

  1. video field does not catch the event too.

SHOULD DO.

  1. 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.

  1. icon_picker does not work too

SHOULD DO

  1. 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:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
tabacitucommented, Jun 10, 2022

@pxpm let’s centralize our testing in this table, using this demo branch. Legend:

  • ? haven’t tested
  • βœ… tested, works
  • 🟨 tested, doesn’t work and it should
  • ❌ doesn’t work but we’re not going to do it right now
  • ⛔️ not applicable
Field onChange() hide() show() enable() disable() require() unrequire() Custom
checkbox βœ… βœ… βœ… βœ… βœ… βœ… βœ… βœ… check(), βœ… uncheck()
checklist βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
checklist_dependency βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
color βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
custom_html ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️
date βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
datetime βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
email βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
enum βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
hidden βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
month βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
number βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
password βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
radio βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
range βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select (1-n relationship) βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select_grouped βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select_multiple (n-n relationship) βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select_from_array βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
summernote βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
text βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
textarea βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
time βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
upload βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
upload_multiple βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
url βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
view ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️
week βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
address_algolia PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
address_google PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
browse PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
browse_multiple PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
base64_image PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
ckeditor PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
color_picker PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
date_range PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
date_picker PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
datetime_picker PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
easymde PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
icon_picker PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
image PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
relationship PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
repeatable PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2 (1-n relationship) PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_multiple (n-n relationship) PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_nested PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_grouped PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select_and_order PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_from_array PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_from_ajax PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
select2_from_ajax_multiple PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
table PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
tinymce PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
video PRO βœ… βœ… βœ… βœ… βœ… βœ… βœ… -
wysiwyg PRO ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️ ⛔️
1reaction
pxpmcommented, Jun 10, 2022

@tabacitu from my last tests (with pending pr’s merged) it’s only missing:

  • repeatable
  • enum
  • address_google
  • checklist_dependency
  • date_range
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found