0

I'm trying to figure out how to add an editable grid field to my channel form - there is very sparse (i.e. none) documentation for this at the moment.

Basically I just need a logged in user to edit the existing grid field and also to add new rows. However, I don't want all fields to be display, so I need to use a custom_fields type of loop rather than just {field:grid_field_name}.

Even using {field:grid_field} in the form doesn't seem to work very well - I get the 'Add Row' button, but clicking it does nothing at all.

Anyone got this working yet?

2 Answers 2

1

@Derek is correct. Simply use the {field:grid_name} within the {exp:channel:form} tag pair. Make sure you also include the channel form css: <link href="{path=css/_ee_channel_form_css}" type="text/css" rel="stylesheet" media="screen">

Lastly, if you're loading jQuery already you could run into some issues as the channel:form will load jQuery as well and you may receive errors and general oddities. You may want to add the include_jquery="no" parameter in the form tag.

You may also need to move jQuery to the head of your document if you do the above. I was getting errors as the fields were attempting to access jQuery before it was loaded.

1
  • Thanks, bro. This below line is work for me to solve click of add new row button. You may also need to move jQuery to the head of your document if you do the above. I was getting errors as the fields were attempting to access jQuery before it was loaded. Commented Mar 9, 2020 at 9:41
1

As it stands, {field:grid_name} is (as far as I know) the only supported way to use a Grid field in a Channel Form. I do see that the docs make note of Grid fields under the {custom_fields} section, but they then show simply using {display_field} when you encounter a Grid field within the Custom Fields loop.

The markup and interaction is pretty complex, so I guess they figure it's too difficult to support.

If {field:grid_name} is not functioning as expected, make sure you haven't set include_assets="no", and that you've loaded the Channel Form CSS styles as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.