Problems with input page and use of multiple <hot-input> tags

15 views
Skip to first unread message

Ed Gomolka

unread,
Nov 7, 2016, 10:54:39 PM11/7/16
to Hobo Users
Hi:
I am having some problems with a complex input page. I use this page to create an object which has many "belongs_to" dependencies. The choice of one dependency affects other dependencies. I use the <hot-input> tag to narrow down selection option options as the user moves down the page. I think that I am missing something very basic, but I'm not sure what it is. Hopefully someone can point me in the right direction.

I am using hobo 2.2.6 under rails 4.2.6.

In order to avoid conflicts between multiple <hot-input> tags, I broke the page down into parts. Here is a simplified version of what I created:

<extend tag="form" for="InputTest">
  <old-form merge>
   <field-list: replace>
      <do part="InputTest-1">
        <field-list fields="input_one">
          <input_one-view:>
            <hot-input update="InputTest-2">
                <select-one options="&InputOne.user_view(...)" include-none="&true" blank-message="..."/>
            </hot-input>
          </input_one-view:>
        </field-list>
      </do>
      <do part="InputTest-2">
       <field-list fields="input_two">
          <input_two-view:>
            <if test="&this_parent.input_one">
              <hot-input update="InputTest-3">
                <select-one options="&this_parent.input_one.input_two" sort="true" include-none="&true" blank-message="..."/>
              </hot-input>
            </if>
            <else>
              <select disabled><option>First select input_one</option></select>
            </else>
          </input_two-view:>
        </field-list>
      </do>
      <do part="InputTest-3">
        <field-list fields="input_three">
          <input_three-view:>
          .........
          </input_three-view:>
        </field-list>
      </do>
    .....
    </field-list:>
  </old-form>
</extend>

This works fine if the user fills everything out as intended. That is if the user selects input_one, the options for input_two are present. If the user then selects input_two, the options for input_three are present, and so on down the list.

If however, the user  doesn't enter everything perfectly, the page won't work:

  1. If the user makes the input_one selection, and then decides to re-select for input_one, the change isn't picked up immediately by the input_two selection list. I need to select input_one a third time, and then the input_two selection list reflects my second input_one selection. In other words, I have a lag.
  2. If I avoid entering any fields at all and simply hit the create button at the bottom of the page, the field validations that I have in the model prevent the object from being saved (just as intended), but the page stops functioning. I can still select input_one, but the input_two selection no longer adjusts to reflect the input_one selection. The log file shows "NoMethodError (undefined method `input_one' for #<InputTest::ActiveRecord_Relation:0x404c140e>)".

Any help would be appreciated.


Thx,

Ed

Ed Gomolka

unread,
Nov 22, 2016, 12:22:55 AM11/22/16
to Hobo Users
I resolved this. I don't know if the solution will be of use to anyone, but here it is, for what it's worth:

Problem 1:

"If the user makes the input_one selection, and then decides to re-select for input_one, the change isn't picked up immediately by the input_two selection list. I need to select input_one a third time, and then the input_two selection list reflects my second input_one selection. In other words, I have a lag."

This was the result of some bad controller logic in my code. I have logic that allows the user to navigate to another page to create a new object that can be used on the original page. The user is automatically returned when the object is created, and any information that they entered previously on the original page is used to re-populate the page. The page re-population logic should have only been triggered upon returning from a specific page, but it was mistakenly being triggered after a validation failure, which led to some very odd behavior. I added an extra check in the controller logic to ensure that the page isn't being repopulated with saved data when the referring page is the current page.

Problem 2:

"If I avoid entering any fields at all and simply hit the create button at the bottom of the page, the field validations that I have in the model prevent the object from being saved (just as intended), but the page stops functioning. I can still select input_one, but the input_two selection no longer adjusts to reflect the input_one selection. The log file shows "NoMethodError (undefined method `input_one' for #<InputTest::ActiveRecord_Relation:0x404c140e>)"."

I resolved this by eliminating most of the page parts (the <do part...> tags). I had created multiple parts in order to resolve an apparent conflict between multiple hot-input tags, but it turned out that my bad controller logic was the actual trigger of the perceived conflicts. Once I fixed the controller code, I was  able to get rid of the many table parts. That resolved problem 2 without any negative repercussions.

Ed

Ibon Castilla

unread,
Nov 22, 2016, 5:55:53 AM11/22/16
to hobo...@googlegroups.com
Thanks for sharing Ed :)

Best regards, Ibon.

Abrazo, Ibon.

Usa Software Libre, tus úlceras te lo agradecerán
Realizado con Software Libre.
--
GPG public key at http://sinanimodelucro.net/ibon_gmail.asc
Finderprint: 1761 59B9 6DE6 0402 31B9 1872 178F A6FD 75F9 EB29

El 22/11/16 a las 06:22, Ed Gomolka escribió:
> I resolved this. I don't know if the solution will be of use to anyone,
> but here it is, for what it's worth:
>
> *Problem 1:*
> "If the user makes the input_one selection, and then decides to
> re-select for input_one, the change isn't picked up immediately by the
> input_two selection list. I need to select input_one a third time, and
> then the input_two selection list reflects my second input_one
> selection. In other words, I have a lag."
>
> This was the result of some bad controller logic in my code. I have
> logic that allows the user to navigate to another page to create a new
> object that can be used on the original page. The user is automatically
> returned when the object is created, and any information that they
> entered previously on the original page is used to re-populate the page.
> The page re-population logic should have only been triggered upon
> returning from a specific page, but it was mistakenly being triggered
> after a validation failure, which led to some very odd behavior. I added
> an extra check in the controller logic to ensure that the page isn't
> being repopulated with saved data when the referring page is the current
> page.
>
> *Problem 2:*
> 1. If the user makes the input_one selection, and then decides to
> re-select for input_one, the change isn't picked up immediately
> by the input_two selection list. I need to select input_one a
> third time, and then the input_two selection list reflects my
> second input_one selection. In other words, I have a lag.
> 2. If I avoid entering any fields at all and simply hit the create
> button at the bottom of the page, the field validations that I
> have in the model prevent the object from being saved (just as
> intended), but the page stops functioning. I can still select
> input_one, but the input_two selection no longer adjusts to
> reflect the input_one selection. The log file shows
> "NoMethodError (undefined method `input_one' for
> #<InputTest::ActiveRecord_Relation:0x404c140e>)".
>
> Any help would be appreciated.
>
>
> Thx,
>
> Ed
>
> --
> You received this message because you are subscribed to the Google
> Groups "Hobo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hobousers+...@googlegroups.com
> <mailto:hobousers+...@googlegroups.com>.
> To post to this group, send email to hobo...@googlegroups.com
> <mailto:hobo...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/hobousers.
> For more options, visit https://groups.google.com/d/optout.

signature.asc
Reply all
Reply to author
Forward
0 new messages