Forum OpenACS Q&A: Re: break out of a multiple tag?

Collapse
Posted by tammy m on
Hi Don,

As you say you *always* want to write your queries to return the exact number of rows you're going to display, I totally agree.

But (knew this was coming!) in my case, I have selected just what I need out of the database and am only wanting to break or continue so that I can pair certain of these selected widgets together in my resulting HTML table. Not because I don't want them at all! If I could break or continue in my form style, I could have a special case for just a few widgets , thus pairing them in a table row. So there are gonna be special cases where it's not bad programming (and most languages have these commands). And regardless of language enforcements, etc, programmers will always come up with ways to do the wrong thing!

Anyway that aside, I can do what Tilmann suggested with the enclosing if to accomplish the effect I'm after. But it is much harder to see the logic this way. You have to find the end of the if which is just not visibly available, since the file is long. Easy to work around yes but just not as clear to anyone reading the code, IMO. But not to start a flame about minor issues, I'm quite happy with my end result:)

thanks again everyone

Collapse
Posted by Tilmann Singer on
Tammy, are you sure you can't achieve what you want using the <group> tag? If there is a common attribute that is the same for those elements that you want to display in the same table row it should be possible, no?

Unfortunatly 'sections' don't add that attribute value to each element but rather insert their own separator element as far as I remember. But maybe you can add your own or add some semantics to the element id.

Collapse
Posted by tammy m on
Hey,

You may be on to something with the <group> tag! I can't find any attributes my form elements that I want to group share though. Is there a way I can add an attribute to my form elements? Then I could use <group> like is done for the section element in form styles.

Functionally, the 'sections' do put a separator in but the code to do it in the adp looks like <group column="section"> so I think it does this by adding an attribute to each element in a 'section.'

Collapse
Posted by Jeff Davis on
Here is a code snippet from acs-templating/resources/forms/standard.adp with a break. It's ugly and bad practice, but it does work (and I think might point to some places where it might make some sense to have a break tag).
<multiple name="elements">
  <if @form_properties.show_required_p@ true>
    <if @elements.optional@ nil and @elements.mode@ ne "display" and @elements.widget@ ne "inform" and @elements.widget@ ne "select" and @elements.widget@ ne "h
idden" and @elements.widget@ ne "submit">
       <span class="form-required-mark">*</span> #acs-templating.required# 
       <% break %>
    </if>
  </if>
</multiple>
Collapse
Posted by tammy m on
Wow,

Thanks Jeff:) How did I miss that?! I have been looking at form style standards all day. Bad eyes? Not to mention that, looking at the sample you posted, it seems so obvious now. Sigh. Programming is sometimes not so easy on the ego!