Static Forms

Field Configuration
Properties
Property
Expected value
Description
Traditional Syntax
DSL Syntax
References to records

Last updated


Last updated
include ForestAdmin::Types
@create_agent.customize_collection('customer') do |collection|
collection.add_action(
'Charge credit card',
BaseAction.new(
scope: ActionScope::SINGLE,
form: [
{
type: FieldType::NUMBER,
label: 'amount',
description: 'The amount (USD) to charge the credit card. Example: 42.50',
is_required: true
}
]
) do |context, result_builder|
record = context.get_record(['stripeId', 'address:country'])
form_values = context.form_values
# ... charge the credit card ...
result_builder.success(message: 'Amount charged!')
end
)
end@create_agent.collection :companies do |collection|
collection.action 'Charge credit card', scope: :single do
form do
field :amount, type: :number,
description: 'The amount (USD) to charge the credit card. Example: 42.50'
end
execute do
company = record(['stripeId', 'address:country'])
amount = form_value(:amount)
# ... charge the credit card ...
success 'Amount charged!'
end
end
endinclude ForestAdmin::Types
@create_agent.customize_collection('ticket') do |collection|
collection.add_action(
'Assign ticket',
BaseAction.new(
scope: ActionScope::SINGLE,
form: [
{
label: 'Assignee',
description: 'The user to assign the ticket to',
type: FieldType::COLLECTION,
collection_name: 'user',
is_required: true
}
]
) do |context, result_builder|
# Retrieve user id from the form
user_id = context.form_values['Assignee']
end
)
end