Upgraded to latest build from Git causing problem with form

54 views
Skip to first unread message

Bob Sleys

unread,
Sep 27, 2011, 3:07:38 PM9/27/11
to hobo...@googlegroups.com
As stated in the subject I've updated to the latest code for rails3 from git and now the below form tag isn't working correctly anymore.  First the filed list is empty, IE I end up with a Create button but no fields to fill out.  I  also end up with two forms on the page, seen only be examing the html.  Both the form tag and the resulting html are below.

<extend tag="form" for="Space">
  <old-form merge>
    <field-list: fields="name, space_dwgid, description,  locations"/>
    <after-field-list:><%= hidden_field_tag(:form_x) %><%= hidden_field_tag(:form_y) %></after-field-list:>

    <cancel: to="&this.floor.spaces"/>
  </old-form>
  <old-form append>
    <if test="&this.floor">
      <if test="&this.floor.layout_file_name?">
        <canvas id="map" class="floorplan" width="870" height="600"></canvas>
        <script language='JavaScript' type='text/javascript'>
          window.onload = function() {
            var m = new ERMap('map');
            m.addImage("#{this.floor.layout.url :jpg }", #{this.floor.layout_width}, #{this.floor.layout_height});
            m.addDwgOrigin("/images/cursors/target-red.png", 48, 48,
                    #{this.scaled_x}, #{this.scaled_y},
                    "form_x", "form_y");
          }
        </script>
      </if>
    </if>
  </old-form>
</extend>

Resulting HTML 

<div class="section content-body">
 <form action="/spaces/1-hall-a" class="space" method="post">
   <div class="hidden-fields">
     <input id="_method" name="_method" type="hidden" value="PUT" />
     <input id="page_path" name="page_path" type="hidden" value="/spaces/1-hall-a/edit" />
     <input name="authenticity_token" type="hidden" value="en5CiCa1XX90acJbm1EVgX9x0hI8ZHh1TyiUW/osVgw=" />
   </div>
   <input id="form_y" name="form_y" type="hidden" />
   <div class="actions">
     <input class="button submit-button" type="submit" value="Save Space" /> or <a class="cancel spaces-link" href="/floors/1-first-floor/spaces">Cancel</a>
   </div>
 </form>
 <form action="/spaces/1-hall-a" append="true" class="space" method="post">
   <div class="hidden-fields">
     <input id="_method" name="_method" type="hidden" value="PUT" />
     <input id="page_path" name="page_path" type="hidden" value="/spaces/1-hall-a/edit" />
     <input name="authenticity_token" type="hidden" value="en5CiCa1XX90acJbm1EVgX9x0hI8ZHh1TyiUW/osVgw=" />
   </div>
   <canvas id="map" class="floorplan" width="870" height="600"></canvas>
<script language='JavaScript' type='text/javascript'>
window.onload = function() {
var m = new ERMap('map');
m.addImage("/system/layouts/1/jpg/BV-main%20level%20FP%2001-hazmat.jpg?1314970057", 3024, 2160);
m.addDwgOrigin("/images/cursors/target-red.png", 48, 48,
1512.0, 1.0,
"form_x", "form_y");
}
</script>
 </form>
</div>

kevinpfromnm

unread,
Sep 27, 2011, 3:33:57 PM9/27/11
to hobo...@googlegroups.com
I remember matt saying something about 3.10 changing the behavior of tags that formerly took <% to now use <%=.  Have you tried edge hobo with it?

Bob Sleys

unread,
Sep 29, 2011, 1:30:16 PM9/29/11
to hobo...@googlegroups.com
I've narrowed this down to the <after-field-list> line copied below.  When I'm trying to do is add some additional hidden field to the form.  Is there some other method I should be using?  It worked fine in RC2 but causes the entire form to be blank in the latest code from Git.

    <after-field-list:><%= hidden_field_tag(:form_x) %><%= hidden_field_tag(:form_y) %></after-field-list:>

Bob

Bob Sleys

unread,
Sep 29, 2011, 2:29:57 PM9/29/11
to hobo...@googlegroups.com
This is defiantly a bug with <after- /><append- /> etc tags and <%= %> code.  The code in the <%= %> is replacing the original tag code instead of being placed in the appropriate spot along with the original code.  My work around is below.  Basically I totally replace the <actions:> tag of the form since I can't append code to a tag without loosing the original tag code and since the actions tag is smaller its less code to duplicate in my tag.

    <actions:>
      <%= hidden_field_tag(:form_x) %><%= hidden_field_tag(:form_y) %>
      <submit label="#{ht 'building.actions.save', :default=>['Save']}" /><or-cancel to="&this.floor.spaces" />
    </actions:>

Bob

kevinpfromnm

unread,
Sep 29, 2011, 2:56:05 PM9/29/11
to hobo...@googlegroups.com
Odd, you don't have a before-field-list call as well do you?

Bob Sleys

unread,
Sep 29, 2011, 3:08:03 PM9/29/11
to hobo...@googlegroups.com
No the original full tag is in the first posting here.

If I place just plain text in the after-field-list tag for example

 <after-field-list:>test</after-field-list>

It works fine adding the word test after the rest of the field list.  However once I use a <%= code goes here %> the original field list goes poof to be placed with the code in the <%= %>.  

Note I also tried with the actions as in <append-actions:><%= code %></append-actions> and the same thing happened I lost the action button and was only left with my code.  This is why I ended up just replacing the entire actions tag as a work around.

Bob

Ignacio Huerta

unread,
Oct 1, 2011, 12:04:17 PM10/1/11
to Hobo Users
Hi,

I think I also hit the same bug:
https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/970-regression-prepend-has-stopped-working-with-latest-changes#ticket-970-2

In my case I'm not using <% or <%=, but just a simple h1 inside of a
prepend parameter:

<show-page:>
<prepend-content-body:>
<h1>Hello</h1>
</prepend-content-body:>
</show-page:>


After some testing I can confirm that this problem is related to the
changes in the Dryml engine:
https://hobo.lighthouseapp.com/projects/8324/tickets/966-dryml-is-incompatible-with-rails-3-block-helpers

Regards,
Ignacio

Bob Sleys

unread,
Oct 7, 2011, 12:12:46 PM10/7/11
to hobo...@googlegroups.com
This issue keeps cropping in up many forms.  Here is my latest issue that I don't have a workaround for yet. Basically I'm looping though a scoped set of data building a text string I then want to pass though Redcloth to display in a div tag.  the problem is all the results of the <% %> code it being output into the html which isn't right only code with <%= %> should result in output.  In the end I end up with a my text in the div tag twice, once for when the temp string in build and then again for when it's passed though RedCloth.  Code below for reference.  Highlighted code should not result in output to the page, but currently does.  Note this worked in previous hobo builds fine.

app/views/floors/show.dryml

<show-page>
  <content-body: >
    <div id="controls">
      <%=image_tag "cursors/zoom-in.png", :onmousedown => "map.zoom(1.25, 400, 300)" %><br/>
      <%=image_tag "cursors/zoom-out.png",:onmousedown => "map.zoom(0.75, 400, 300)" %>
    </div>
    <canvas id="floorplan" width="800" height="600" ></canvas>
    <div class="info" id="info">Mouse over markers on drawing to see additional info<br/>Shift Click on map to
      lock/unlock info.
    </div>
    <repeat with="&@positive_spaces">
      <div class="info" id="#{this.space_dwgid}" style="display: none;">
        <% t = "*#{this.name}*" %>
        <repeat with="&this.locations">
          <% t << "\n#{this.name} contains" %>
          <repeat with="&this.materials">
            <% t << "\n#{this.name} positive for "%>
            <repeat with="&this.samples">
              <% t << "#{this.sample_type} "%>
            </repeat>
          </repeat>
        </repeat>
        <%= begin
            textilized = RedCloth.new(t, [:hard_breaks])
            textilized.hard_breaks = true if textilized.respond_to?("hard_breaks=")
            textilized.to_html.html_safe
            rescue => e
                "[Uh oh - looks like there was a problem with this RedCloth]"
            end
        %>
      </div>
    </repeat>
    <script language='JavaScript' type='text/javascript'>
        var map;
        window.onload = function() {
            map = new ERMap('floorplan', 'info');
            //add floorplan
            map.addImage("#{this.layout.url :jpg}", #{this.layout_width}, #{this.layout_height});
            //add hot spots
            <repeat with= "&@positive_spaces" >
                    map.addIcon("/images/cursors/hotspot.png", 25, 25, #{this.scaled_x}, #{this.scaled_y}, "#{this.space_dwgid}");
            </repeat>
        };
    </script>
    <if test="&current_user.employee?">
      <field-list fields="layout_file_name, drawing_scale, csv_file_name" />
      <h4><a to="&this.spaces">List of Floor Spaces</a></h4>
    </if>
  </content-body:>

</show-page>

Matt Jones

unread,
Oct 9, 2011, 4:18:37 PM10/9/11
to hobo...@googlegroups.com

On Sep 29, 2011, at 1:30 PM, Bob Sleys wrote:

> I've narrowed this down to the <after-field-list> line copied below. When I'm trying to do is add some additional hidden field to the form. Is there some other method I should be using? It worked fine in RC2 but causes the entire form to be blank in the latest code from Git.
>
> <after-field-list:><%= hidden_field_tag(:form_x) %><%= hidden_field_tag(:form_y) %></after-field-list:>

I've fixed this:

https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/970

Gory details on the ticket. :)

Still digging on the <repeat> issue turning <% %> tags into output - looks like it's a different bug.

--Matt Jones

Matt Jones

unread,
Oct 9, 2011, 7:01:47 PM10/9/11
to hobo...@googlegroups.com

I *think* I've got this fixed now. There's a lot of confusing code revolving around new_context, which has two different places to tap the output (from the buffer and from the return value of the block). I've left a scrap of debug code in for the moment; any reports of DRYML code that dumps a line like this:

new_context: /some/backtrace/path:42

would be GREATLY appreciated. I'm also going to start working on a full-on DRYML test suite, as there are way more corner-cases than I would have believed possible...

--Matt Jones

Owen Dall

unread,
Oct 10, 2011, 9:22:45 AM10/10/11
to hobo...@googlegroups.com
Thanks much for tracking this down, Matt.


--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.




--
Owen Dall, Chief Systems Architect
Barquin International

Bob Sleys

unread,
Oct 10, 2011, 10:48:17 AM10/10/11
to hobo...@googlegroups.com
Thanks Matt,  I appreciate all the hard work you put into this.  I need to spend a bit of time myself and see if I can figure out the core Hobo code.

Thanks again

Bob
Reply all
Reply to author
Forward
0 new messages