Bug #23181 Bug Fixed

Cannot delete all rows from Grid field in Channel Forms using {display_fields} tag

Version: 3.5.10 Reporter: seavers

This is similar to the bug report in EE2.9.2:

https://expressionengine.com/support/bugs/20718/cannot-delete-all-rows-from-grid-field-in-channel-forms

However, it affects the {display_fields} tag rather than the {field:field_name} tag.

When using {display_fields} within the {custom_fields} tag pair, you cannot delete the last remaining row of a grid field. The field display is removed when the delete icon is pressed, and is replaced by the notice to add a row. But when saved, the field does not pass an empty array for the field/row value to the ee()->grid_lib->save() method and therefore the row is not deleted from the database.

Here’s the code (as per the documentation https://docs.expressionengine.com/latest/channel/channel_form/index.html#id71):

{custom_fields}{display_field}{/custom_fields}

I can confirm that {field:field_name} tag works as it should, and you are able to delete the last remaining row.

  • Correction - cannot get it working with {field:field_name}. I’m using the following workaround:

    <link href=”{path='css/_ee_channel_form_css'}” type=”text/css” rel=”stylesheet” media=”screen”> {exp:channel:form channel=”test” entry_id=”1”}

    &lt;label&gt;Title&lt;/label&gt;
    &lt;input name="title" type="text" value="{title}"&gt;
    
    &lt;label&gt;Test grid&lt;/label&gt;
    &lt;input type="hidden" value="" name="test_grid[]"&gt;
    &#123;field:test_grid&#125;
    
    &lt;input type="submit" value="Submit"&gt;
    

    {/exp:channel:form}

    Note the hidden field.

    seavers
    24th July, 2017 at 4:41am
  • Thanks for the report! We’ve got it fixed up for the next release- should work in the loop and using {field:field_name}.

    For the short term, the hidden field should work fine, though if you need a patch, just let me know.

    Robin Sowell
    02nd August, 2017 at 5:26pm
  • Thanks Robin. Will {custom_fields}{display_field}{/custom_fields} also work with grids?

    seavers
    03rd August, 2017 at 4:36am
  • It should- I tested with that as well.

    I went ahead and attached the updated file in the solution tab so you can try it out. If you run into any problems with it, just let me know.

    Robin Sowell
    03rd August, 2017 at 11:02am
  • Thanks Robin.

    seavers
    18th August, 2017 at 6:36am

You must be signed in to comment on a bug report.

  • Backup and replace system/ee/EllisLab/Addons/channel/libraries/channel_form/Channel_form_lib.php with the one in the attached zip.

ExpressionEngine News

#eecms, #events, #releases