We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Grid Field Validation with Ansel

Developer Preview

TJ Draper's avatar
TJ Draper
222 posts
7 years ago
TJ Draper's avatar TJ Draper

I’m having a problem with Grid field validation and Ansel. Particularly in this case, if there are two Ansel fields in a grid and both require at least one image.

  • When you upload an image to the first field, validation kicks in on the Grid field overall.
  • Validation sees that the second Ansel field is missing a required image so it disables the submission buttons for the entry and turns them red. It also inserts the error message “There was a problem with one or more Grid fields” but that message is being inserted into the Ansel field instead of the Grid field (I assume because the JS selectors being used are too generic).
  • Uploading an image to the second Ansel field triggers validation, which returns okay, but the errors don’t go away and the save entry buttons are not re-enabled.

Here is a video demonstrating this issue.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
7 years ago
Kevin Cupp's avatar Kevin Cupp

Strange one. I can’t reproduce with our fields so it’s likely something you should be able to change on your end. The “There was a problem with one or more Grid fields” shouldn’t show up for AJAX validation, we only validate the individual fields inside the Grid that are interacted with, not the entire Grid, so something is happening where it thinks that message is the result of your fieldtype’s validation and placing it in your fieldtype’s cell, the selectors should be fine. There’s a lot going on here, probably quicker if you could send me a copy of Ansel if you don’t mind?

       
TJ Draper's avatar
TJ Draper
222 posts
7 years ago
TJ Draper's avatar TJ Draper

Ansel is a free download here and can trial for 30 days. If you’ve used Ansel on the install you work from before and it’s been more than 30 days I can PM you on how to reset the trial. https://buzzingpixel.com/software/ansel-ee/download

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
7 years ago
Kevin Cupp's avatar Kevin Cupp

I think what’s going on is the input you’re triggering the change event on isn’t the base name of the field, it’s suffixed with [placeholder]. This is unexpected, but I think we can and probably should account for that on our end. So, you can either wait for a release from us, or change your input name. Here is the change to EE I would make:

Open system/ee/EllisLab/Addons/grid/libraries/Grid_lib.php and find this code on line 554:

if ($field == 'field_id_'.$this->field_id.'[rows]['.$row_id.']['.$col_id.']'

And REPLACE it with:

if (strpos($field, 'field_id_'.$this->field_id.'[rows]['.$row_id.']['.$col_id.']') === 0
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.