form-helpers

In rails, whether to use form helpers or not to?

In rails, is it recommended to use form helpers? Internally, everything boils down to plain html then why not write the html directly? Performance will obviously be better in writing direct html than using helpers. Is using form helpers like a convention or something that rails developers must follow? ...

Codeigniter form_helper getting database rows to be values in select menu

I know this is going to be really simple once I post it, I am writing a form, which has a select menu in it, I want the values to pulled from the database, so I thought it would be something along these lines, My view <?php echo form_open('admin/save_content'); echo form_fieldset(); echo form_dropdown('categories', $select_o...

CakePHP: Prevent GET form fields in URL

I've got a CakePHP search form that has 'type'=>'get'. Basically, one of the elements in the form is a submit button of type image. When the form is posted, in the URL I always get these x & y coordinates of the image submit button: http://site.com/controller/action?x=22&amp;y=36&amp;query=hello Is there any way I can prevent the coor...

Problem passing URL variables in post form submission with CakePHP FormHelper

Hi there, I'm writing my first CakePHP application and am just writing the second part of a password reset form where a user has received an email containing a link to the site and when they click it they're asked to enter and confirm a new password. The url of the page is like this: /users/reset_password_confirm/23f9a5d7d1a2c952c01af...

Cakephp FormHelper not outputting "<form>" tags

Hi, So I have a users controller with an action called "selfView" it looks like this: (*users_controller.php*) function selfView() { $user = $this->User->find('first', array('conditions' => array('User.id' => $this->Auth->user('id')))); $formms = $this->Form->find('all', array('fields' => array('Form.id', 'Form.name'), 'recursive' ...

"Automagic" output fields in CakePHP?

I'm currently using CakePHP's "automagic" field elements for my CRUD forms. By this I mean I'm using the echo $form->input('fieldname', $options); method to generate everything. This chooses the correct element type, and wraps everything into a div with a <label> element. Now I have some fields that are not editable, but i'd like f...

Use custom id for check_box_tag in Rails

How do you set a custom id when using a check_box_tag helper in rails? I have a loop which creates a bunch of checkboxes based on a collection: - subject.syllabus_references.each do |sr| = check_box_tag 'question[syllabus_reference]', sr.id, :id => sr.id = label_tag sr.id, sr.name I would like to set a custom id so that m...

Rails FormTagHelper missing important select and collection_select methods

You can do this when you use form_for(@model...): collection_select(:subscription, :duration, ["Some", "Values"], :to_s, :to_s, {:prompt => true}) And the output is something like this: <select id="subscription_duration" name="subscription[duration]"> <option value="">Please select</option> <option value="Some">Some</option> ...

Ruby on Rails: How to use a local variable in a collection_select

I'm trying to create a <select> element using the collection_select method, but it seems that in order for the proper <option> to be selected, the identifier passed into collection_select needs to be an instance variable and not a local variable (this is happening in a partial). So when I create a <select> for the categories of a produc...

Ruby on rails: Select options menu with default value attribute

I need to produce a select menu with a Default value on the list of <options> . Here is how I need it looks like. <select name="menu[parent_id]" id="menu_parent_id"> <option value="0">==None==</option> <option value="34">TEST</option> </select> Currently I use this select helper in my form <%= f.select(:parent_id, @parent_menus....

CakePHP: shortcomings with indirectly associated models

I'm having some issues with dealing with indirectly associated models in cakephp. My current model setup is as follows: Deliveries hasOne License License belongsTo Delivery License hasAndBelongsToMany Product (and vice-versa) License hasAndBelongsToMany ProductOption (and vice-versa) I'm trying to save information about ALL of these ...

Reusing form_for in view for a mailer errors on forgery

I have a form_for in a template new.html.erb where I do the normal save to the DB and then an e-mail on success. I want the mailer to send the same new.html.erb as the body and pass the model so that the form is fully populated. I'm getting the following error: undefined method `protect_against_forgery?' for #<#<Class:0x000000049d7110>:...

Ruby on Rails form f.text_area contains additional spaces

I have a quite average form in Rails, trough blog_kit <% form_for(@blog_post, :html => { :multipart => true }) do |f| %>\ ... other code <%= f.text_area :body %> <%= debug(@blog_post) %> When editing a blog-post, the body suddenly contains additional spaces (marked as _ to visualise): ...sit amet eleifend diam imperdiet pharetr...

Codeigniter form_dropdown issues

I need a bit of help. I have this in my view $salutation = array( 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Dr.' => 'Dr.', ); echo form_open('membership/update'); echo form_dropdown('Salutation', $salutation, 'Mrs.'); The dropdown works in all but one fashion, it does not pre-select 'Mrs.'. How ...

Rails inconsistently fails to send datetime parameters

I am revising someone else's project which allows users to submit content either for either immediate or scheduled publication. There are a pair of radio buttons to select this, and a datetime field that is enabled by javascript if the radio button for 'scheduled' is selected <%= f.hidden_field :scheduled_state %> <%= f.radio_button :im...

How can I add a red error message for wrong input in the form in rail3?

So in rails, if any of the input is not valid, the page returns back to the input page and red errors will show up next to that input_text or textarea. For example, <% validates_presence_of :email %> It will say the error at the top, and the email input text turns into red. However, when I separately made a valid checking statement...