Class: Decidim::Budgets::Admin::BudgetForm

Inherits:
Form show all
Includes:
TranslatableAttributes
Defined in:
decidim-budgets/app/forms/decidim/budgets/admin/budget_form.rb

Overview

This class holds a Form to create/update budgets from Decidim's admin panel.

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Methods inherited from AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#decidim_scope_idObject

Scope identifier

Returns the scope identifier related to the meeting


33
34
35
# File 'decidim-budgets/app/forms/decidim/budgets/admin/budget_form.rb', line 33

def decidim_scope_id
  super || scope&.id
end

#scopeObject

Finds the Scope from the given decidim_scope_id, uses the compoenent scope if missing.

Returns a Decidim::Scope


26
27
28
# File 'decidim-budgets/app/forms/decidim/budgets/admin/budget_form.rb', line 26

def scope
  @scope ||= @attributes["decidim_scope_id"].value ? current_component.scopes.find_by(id: @attributes["decidim_scope_id"].value) : current_component.scope
end