A developer's journey through BrowserCms.

Tuesday, June 4, 2013

Resolving undefined method 'cms_number_field'

After creating a custom content block for BrowserCms, if you had specified any 'integer' type in your generate command, you might see something like this when you go to create an instance of that content:

NAMESPACE=bcms_my401k ./bin/rails g cms:content_block BcmsMy401k::Widget user_id:integer name:string description:text
For some reason, when generating content blocks, integers are mapped to ‘cms_number_field’ form helpers, but they don’t seem to exist.

To resolve this issue, we simply need to provide the missing components that BrowserCms is complaining about.
  1. include 'number_field' in the list of form helper methods generated at load time
  2. associate a partial with the new form helper


Although this solution (creating a partial) is currently identical to ‘cms_text_field’, the partial could be updated later to validate a numeric entry.

No comments:

Post a Comment