Fred Editor Open Settings Not Working When Nested

This issue leaves me scratching my head as I do not understand if this is a bug or if I’m just not getting the way the Fred editor works when it comes to elements. I have tried this with creating an embedded drop zone in an element as well but that is not working either.

Here is the issue. I have a client that will be editing their meetings info. Part of this is an embedded Google Map to the venue. I have a simple container in which I have two columns (Bootstrap). One is set to 8 the other 4. The map goes in the 4 width column to the right.

If I set options in my element to add in the code, Fred simply will not save the changes. I can see the ‘Open Settings’ option and it looks fine. But when I apply the change, nada. Will not save. And as soon as I drag in the main element I see an error in the console related to this twig coding. I understand that nothing is being set as far as data yet, but odd that this is happening.

Now, I made a simple element with the exact same option code (but without any styling) and if I drop that on the page everything works fine! I can change the text, add in Google Maps code, whatever.

So I know the coding below works fine. Just not when you are using it inside embedded divs to create structure. Am I missing something obvious or is this a bug?

Options:

{
  "remote": true,
  "settings": [
    {
      "name": "map_code",
      "label": "Map Code",
      "type": "text",
      "value": "Enter Google Map code here..."
    }
  ]
}

Markup:

{% autoescape %}
    {{ map_code|raw }} 
{% endautoescape %}

And here is the code for the structured element to create the client’s styling:

<div class="container" style="margin-top:30px;" data-fred-name="UpcomingMeetingsData" data-fred-editable="true" data-fred-rte="true">
   <div class="col-md-8">
      <p class="meeting-title">TITLE HERE...</p>
      <p class="meeting-presenter"><i>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.</i>
      </p>
      <p class="text-left">
         <button type="button" class="btn btn-default">
           <a href="#">Detailed Event Information</a>
         </button>
      </p>
      <p class="meeting-info"><b>Date</b>: blah blah </p>
      <p class="meeting-info"><b>Time</b>: blah blah </p>
      <p class="meeting-info"><b>Location</b>: blah blah </p>
      <p class="text-left">blah blah blah blah blah blah blah blah blah blah.</p>
      <p class="meeting-button">
         <button type="button" class="btn btn-default">
         <a href="#">Online Event registration</a>
         </button>
      </p>
   </div>
   <div class="col-md-4 map-margin" data-fred-editable="true">
        {% autoescape %}
          {{ map_code|raw }} 
        {% endautoescape %}
   </div>
   <div class="col-xs-12">
      <p class="text-left"> <b class="meeting-title">blah blah blah blah!</b></p>
      <p class="text-left">blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah <b>Pay Now</b>&nbsp;button below.</p>
      <p class="text-left">We look forward to having you and your organization part of our event.</p>
      <p class="text-left">
         <button type="button" class="btn btn-default">
            <a href="#">Form</a>
         </button>
      </p>
   </div>
</div>

This simple gif hopefully will play to show what I mean.

What does the JS error refer to? It’s saying a twig var is undefined, but can’t see any more info. Can you paste the full error text, please?

Possibly remove the data-fred-editable="true" attr from the map-margin col.

** side note you don’t need to use data-fred-editable="true", defining data-fred-name="" will suffice.

1 Like

Like everyone else, developers finally figure out coding problems three hours AFTER we needed to be in bed for work the next day!! There are TWO issues here. I am not sure if this behavior is by design or if these are bugs that need to be addressed.

  1. Your comment about the error message and the data-fred-editable="true" data. Removing this did NOT solve the issue. While it may not be needed, it looks to be harmless if added. The error message was:

Error1

And after messing about, found it was attributed to the {% autoescape %} {% endautoescape %} code. Someone suggested this, but if removed it does not affect anything in the way of pasting in the Google Maps <iframe> code needed. From the error message, it looks like either I am not constructing this properly or it cannot be used like this. I am not a Twig expert so I guess I will have to read up on this over the weekend!
https://twig.symfony.com/doc/3.x/tags/autoescape.html

  1. Now this is where I am not sure if this is a bug or not. After two hours of trying every combination I could think of, it seems that you cannot use any sort of Fred identifier in either the enclosing element around the map_code variable OR the parent element.

So you can’t have this:

<div class="container" style="margin-top:30px;" data-fred-name="UpcomingMeetingsData" data-fred-rte="true">
   <div class="col-md-8">
      <p class="meeting-title">2020 Winter Meeting 4</p>
   </div>
   <div class="col-md-4 map-margin">
        {{ map_code | raw }}
   </div>
   <div class="col-xs-12">
      <p class="text-left"> <b class="meeting-title">Sponsor This Event!</b></p>
   </div>
</div>

because the enclosing div has a Fred name.

However, you can do this because the Fred name is NOT enclosing the other child elements nor the element that is referencing the variable. It is only on the col-md-8 div that needs to be edited.

<div class="container" style="margin-top:30px;">
   <div class="col-md-8" data-fred-name="UpcomingMeetingsData">
      <p class="meeting-title">2020 Winter Meeting 5</p>
   </div>
   <div class="col-md-4 map-margin">
        {{ map_code | raw }}
   </div>
   <div class="col-xs-12">
      <p class="text-left"> <b class="meeting-title">Sponsor This Event!</b></p>
   </div>
</div>

I guess I would have to get creative IF I needed to have that col-md-4 div editable in some way! Luckily, we only need the map to appear and the Open Settings option works well for stuffing the necessary code into it!

Appreciate your reply and guidance. Helped me to experiment to get to the solution as I am just learning MODX and Fred. Thanks.

Jim

1 Like