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?
...
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...
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&y=36&query=hello
Is there any way I can prevent the coor...
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...
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' ...
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...
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...
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>
...
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...
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....
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 ...
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>:...
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...
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 ...
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...
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...