Skip to main content

NewDsl

cm_new

Create a form for the new action.

Parameters

NameTypeDescription
display_nameStringThe display/button name of the page.
page_titleStringThe title of the page.
page_descriptionStringDescription of the page.
partialStringPartial path of the page.
redirect_toProc, nilLambda to redirect after create.
allow_create_actionProcLambda to control whether the Add button is shown.

Example — Creating a new page with redirect

cm_new(display_name: 'Add Post', page_title: "Add Post", page_description: 'Enter all details to add Post', redirect_to: ->(current_object) { "/pages/#{current_object.id}" }) do
cm_section 'Details' do
form_field :title, input_type: :string
form_field :body, input_type: :rich_text
end
end

Method Signature

cm_new(display_name: 'Add', page_title: nil, page_description: nil, partial: nil, redirect_to: nil, allow_create_action: -> { true })