ruby - How do I get an array of check boxes in haml? -


I have an array of stars in a regular form implemented as part of the Serrera server, which is called thethemodels. Models are options for selecting the user, and are received from the end of the back (the idea, as new models are added, then the front end code should not be changed).

I am using Hamil to present HML.

How can I tell each element in the list of @theModels, as each element is a checkbox?

I think that simply inserting

  = @themodels  

and how can I obtain that user by receiving the checkbox Could? Let me list the stars contained in theModels, but not without spaceship or likes, and of course not in the checkbox. I think that sounds like it but my haml-fu is not good enough to change in what I need.

Update:

This option uploads the file, such as the code now:

 % form {: action = & gt; "/ Upload" ,: method = & gt; "Post" ,: enctype = & gt; "Multipart / form-data"} - @ theModelHash.each do | Key, value | % {{Type = & gt; Checkbox}, name = & gt; "# {Key}" ,: value = & gt; 1 ,: checked = & gt; Value} = key% input {: type = & gt; "File",: name = & gt; "File"}% input {: type = & gt; "Submit",: value = & gt; "Upload"}  

The problem is that instead of the end, one file upload button on each option. I only want to submit a button at the end; When I press the 'upload' button, should I have two ways to report the results of both?

UPDATE2:

After a moment's idea, they can be modified in the following versions:

Thanks!

 % form {: action => "/ Upload",: method = & gt; "Post" ,: enctype = & gt; "Multipart / form-data"} - @ theModelHash.each do | Key, value | {= Type = & gt; "Checkbox",: name = & gt; "# {Key}",: value = & gt; 1,: check = & gt; Value} = key% form {: verb = & gt; % Input {= type = & gt; "File" ,: name = & gt; "File"}% input <: type = & gt; "Submit" ,: Value => "Upload"}  

And what I should do to do this

I think you should send content as a hash. This will give you the opportunity to set the initial value in the form.

hash @love will give you results.

For example {"Oranges" => "1"}

 # app.haml% form {: method => 'post' ,: action => "/"} - @model.each. Key, value | Name => "checkbox" ,: name => "# {key}" ,: value => 1,: check => value} = key% input {: type =>: submit: value => "Save"} # app RB requires' Sinatra 'to get' Hamal '/' Do @ Models = {"oranges" => true, "banana" => wrong} haml: app and post '/' @ params.inspect end < / Pre> 

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -