Home > database >  connecting yml to html.slim
connecting yml to html.slim

Time:02-11

There are two html.slim files as:

client view:

= f.input :name,
        required: true,
        :wrapper => :input_wrapper 

company view:

= f.input :name,
        required: true,
        :wrapper => :input_wrapper 

there is shared yml file that defines the displayed values as:

 simple_form:
        labels:
            defaults:
                name: some value

How can I define different name values for the company and the client, ideally without chenging the view? Moreover, how is the yml file linked to the slim file? For example in the routes files it is specified the url and the corresponding view file, how does that work between yml and html.slim files?

CodePudding user response:

In the documentation you will find the following:

simple_form_for @admin_user, as: :some_user will look into the yml file under some_user instead of admin_user so the yml file will look like this:

en:
  simple_form:
    labels:
        admin_user:
            name: Admin Name
        some_user:
            name: Some user name

So in your simple_form you can add as: :client and as: :company and add those 2 to the yml file.

CodePudding user response:

You can assign simple form labels like this:

en:
  simple_form:
    labels:
      client:
        name: Client name
      company:
        name: Company name

Or you can assign attributes like this:

en:
  activerecord:
    attributes:
      client:
        name: Client name
      company:
        name: Company name
  • Related