Create new DO record without leaving admin form

The situation is two data objects.

One holds lots of information.
The other is a related field (many_many) that holds only a title, like a Tags module.

The tags are rendered in the parent DO form with a Checkboxlist field.

The request is to create new tags without leaving the parent DO form.

I had an Admin area for it - they don’t want to leave the page.

I’ve suggested using the TagField where they could create right there, but they want to see all available tags at once and a description of the tag.

I’m assuming there is no “SilverStripe” way of doing that?

I’d need to hack it together with some js/xhr to a controller to create the DO record and pass back the html of the new checkbox for render in the current list. Would SS POST the dynamic field.

Managing a Tag ManyMany relationship in the CMS works really well when using a CheckboxSetField. You need to do this on the front-end now? All you need to do is to add some code like this:


This is totally untested, but I am pretty sure it is not much harder than that. The removeAll is important so that you dont just add stuff, but you also remove tags.

Does that answer your question?

Hi, thanks for replying.

No not really.

The request is to create a new checkbox in the parent DO form without leaving the form, going to the module the related tags are in and creating it there like you usually would.

The related DO tags are displayed in the parent admin form in a checkboxsetfield like this:


What I need is:

  1. A button/link at the bottom of the field to add a new record to the child DO
  2. Clicking it produces some form of UI for creating (probably a modal with a form in it - in this example the DO is only a Title TextField)
  3. Saving in that modal creates the new record and adds it to the list in the picture above and closes the creating modal.

Hi Lance, it might be easier to chat on slack of you like. Would love to help you get it done. It does not sound hard, but I am a bit confused on what exactly you need. You could make something really nice with a bit of AJAX.

Have you tried the TagField? Are you on SS3 or SS4?

Yep, mentioned in first post:

I originally used the TagField but the requirement above killed it.

And yeah, step 3 above would be an XHR/Ajax call back to the server to create/save the new record. Doesn’t have to be a modal UI. Could be a TextField and submit button inline.

I’m using 4.4. Seems SS lacks the ability I’m after out of the box.