# Load value in a date form field

**URL:** <https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195>\
**Category:** Rails\
**Created:** [April 19, 2008, 1:13am UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195 "2008-04-19T01:13:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [April 19, 2008, 1:13am UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195/1 "2008-04-19T01:13:29Z")

</div>

Hi!I think it’s easy but for some reason what I want to do is not  
working. When I call to the new method I do that before render the  
new.html.erb page:

@cambio = Cambio.new  
@cambio.user\_id\_origen = current\_user.id  
@cambio.start\_date = current\_user.date

Debuggin with Aptana I’ve seen that @cambio.start\_date gets the correct  
value, but when the html page renders it can’t fill the form field with  
that value. Anybody knows how can I do that?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [April 19, 2008, 1:51am UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195/2 "2008-04-19T01:51:22Z")

</div>

What does your new.html.erb look like?

It depends of the type of field you are using when trying to display  
the value.

Serge

On Apr 18, 8:13 pm, “Daniel A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [April 19, 2008, 2:14am UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195/3 "2008-04-19T02:14:23Z")

</div>

sergecpelletier wrote:

> What does your new.html.erb look like?
> 
> It depends of the type of field you are using when trying to display  
> the value.
> 
> Serge
> 
> On Apr 18, 8:13 pm, “Daniel A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

# New cambios

\<%= error\_messages\_for :cambios %\>

\<% form\_for(@cambios) do |f| %\>

\<%= f.text\_field :user\_id\_origen %\>

**Fecha origen**  
 \<%= f.date\_select :fecha\_origen %\>

\<%= f.submit "Create" %\>

\<% end %\>

\<%= link\_to ‘Back’, cambios\_path %\>

---

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [April 20, 2008, 3:26pm UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195/4 "2008-04-20T15:26:46Z")

</div>

> ```
> <b>Fecha origen</b><br />
> <%= f.date_select :fecha_origen %>
> 
> ```

Shouldn’t this be f.date\_select :start\_date ?

---

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [April 21, 2008, 4:14pm UTC](https://www.ruby-forum.com/t/load-value-in-a-date-form-field/135195/5 "2008-04-21T16:14:56Z")

</div>

(Yes, start\_date unless it’s been translated for our English-speaking  
group).

Also, it appears that you are using @cambio (singular) in the  
controller and @cambios (plural) in the form\_for of the view.

On Apr 20, 9:26 am, Jan-Christian F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
