select-one-or-new-dialog is a very simple control that depends on a large number of Hobo and hobo-jquery components to be working correctly in the standard manner. These include ajax, a standard form context, and formlets.
Because the select-one is a part, it cannot be parameterized. However, you can adjust its definition by defining the polymorphic input for the type:
<def tag="input" for="StoryStatus"> <select-one include-none="&false" /> </def>
For Hobo ajax to work, standard controller actions are required. If you have customized the sub-item’s create action, you may break select-one-or-new-dialog.
There is one case where you have to customize the create action. For Ajax to work, Hobo has to resurrect the context. This is straightforward if the parent context exists in the database. If it does not, then Hobo uses whatever ‘this’ is created by the controller action. In our case, this is usually the wrong thing.
class Story hobo_model fields do name :string end belongs_to :story_status # plus permissions, etc... end
<new-page> <field-list:> <story-status-view:> <select-one-or-new-dialog/> </story-status-view:> </field-list:> </new-page>
class StoryStatusesController < ApplicationController def create hobo_create do if request.xhr? self.this = Story.new end end end end
Just to be clear, you shouldn’t need any special controller actions if you are using inside of edit forms. It’s only when you’re using it inside of a new form that Hobo cannot load the object from the database so you have to tell it the context.
FIXME: translate ‘or’, ‘New’, ‘cancel’, ‘ok’.
Edit this page