Skip to content

Conversation

@andypike
Copy link

I needed to add a few methods to allow this gem to work with Rails 4.2
and simple_form 3.1. These methods were as follows:

Attribute#number? - returns true if the attribute type is numerical,
otherwise returns false.

Attribute#limit - returns the database column size limit which
simple_form uses to set maxlength/size attributes on the input controls
if there are no length validations. I return nil here so no html
attributes are added. If you add length validations then these do still
result in html attributes for length being added.

SimpleFormObject#has_attribute? - returns true if the passed attribute
has been declared for the form object otherwise returns false.

In addition to these changes I have also added a new class method for
overriding the model name used (for routing). Now you can do this:

class FooForm
  include SimpleFormObject

  route_as :bar
end

This will result in the form using the path helpers bars_path rather
than foos_path etc.

I needed to add a few methods to allow this gem to work with Rails 4.2
and simple_form 3.1. These methods were as follows:

Attribute#number? - returns true if the attribute type is numerical,
otherwise returns false.

Attribute#limit - returns the database column size limit which
simple_form uses to set maxlength/size attributes on the input controls
if there are no length validations. I return nil here so no html
attributes are added. If you add length validations then these do still
result in html attributes for length being added.

SimpleFormObject#has_attribute? - returns true if the passed attribute
has been declared for the form object otherwise returns false.

In addition to these changes I have also added a new class method for
over riding the model name used (for routing). Now you can do this:

```
class FooForm
  route_as :bar
end
```

This will result in the form using the path helpers bars_path rather
than foos_path etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant