Module: Ramaze::Helper::CustomField

Defined in:
lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb

Overview

Helper for the custom fields package.

Since:

Instance Method Summary (collapse)

Instance Method Details

- (CustomFields::Model::CustomField) validate_custom_field(custom_field_id, custom_field_group_id)

Similar to validate_custom_field_group() this method validates a single custom field and returns it if it's valid.

Parameters:

  • custom_field_id (Fixnum)

    The ID of the custom field to validate.

  • custom_field_group_id (Fixnum)

    The ID of the field group the field is supposed to belong to.

Returns:

Since:

  • 0.2.8



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb', line 39

def validate_custom_field(custom_field_id, custom_field_group_id)
  field = ::CustomFields::Model::CustomField[custom_field_id]

  if field.nil?
    message(:error, lang('custom_fields.errors.invalid_field'))
    redirect(
      ::CustomFields::Controller::CustomFields.r(
        :index, custom_field_group_id
      )
    )
  else
    return field
  end
end

- (CustomFields::Model::CustomFieldGroup) validate_custom_field_group(custom_field_group_id)

Validates a custom field group and returns the object if it's valid.

Parameters:

  • custom_field_group_id (Fixnum)

    An ID of a custom field group that has to be validated.

Returns:

Since:

  • 0.2.8



18
19
20
21
22
23
24
25
26
27
# File 'lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb', line 18

def validate_custom_field_group(custom_field_group_id)
  group = ::CustomFields::Model::CustomFieldGroup[custom_field_group_id]

  if group.nil?
    message(:error, lang('custom_field_groups.errors.invalid_group'))
    redirect(::CustomFields::Controller::CustomFieldGroups.r(:index))
  else
    return group
  end
end

- (CustomFields::Model::CustomFieldType) validate_custom_field_type(custom_field_type_id)

Validates a custom field type and returns it if it's valid.

Parameters:

  • custom_field_type_id (Fixnum)

    The ID of the field type to validate.

Returns:

Since:

  • 0.2.8



62
63
64
65
66
67
68
69
70
71
# File 'lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb', line 62

def validate_custom_field_type(custom_field_type_id)
  type = ::CustomFields::Model::CustomFieldType[custom_field_type_id]

  if type.nil?
    message(:error, lang('custom_field_types.errors.invalid_type'))
    redirect(::CustomFields::Controller::CustomFieldTypes.r(:index))
  else
    return type
  end
end