Loading ...
Sorry, an error occurred while loading the content.

909newbie: kok form gwe ga nongol yaa...?

Expand Messages
  • ~inung;
    Dec 1, 2006
    • 0 Attachment
      Temas,

      nanya dong, ada kasus gini:
      gwe pengen bikin simple update form, tp ga pake
      scaffold.
      gwe punya:
      ==

      1. model: app/models/entry.rb
      ##
      class Entry
      attr_accessor :title, :body
      end
      ##

      2. controller: app/controllers/diary_controller.rb
      ##
      class DiaryController < ApplicationController
      def new
      render :layout => "standard"
      @entry = Entry.new
      end
      def preview
      render :layout => false
      end
      end
      ##

      3. views: app/views/diary/new.rhtml
      ##
      <% start_form_tag ({:action=>"save"},
      :id=>"entry_form")%>
      <% text_field :entry, :title %><br />
      <% text_area :entry, :body%><br />
      <% submit_tag "Save" %>
      <% end_form_tag %>
      <%
      observe_form "entry_form",
      :frequency => 1,
      :update => "live-preview",
      :complete => "Element.show('live-preview')",
      :url => {:action => "preview"}
      %>
      <div id="live-preview" style="display: none; border:
      1px solid"></div>
      ##

      4. view: app/views/diary/preview.rhml
      ##
      <h2>Diary entry preview</h2>
      <h3><%= params[:entry][:title]%></h3>
      <%= textilize (params[:entry][:body])%>
      ##

      ==

      nah permasalahannya adalah: pas gwe browse via url :
      http://localhost:3000/diary/new knp engga nongol
      formnya? tapi klo view di point 3 gwe ubah jadi:

      ##
      <form action="save" method="post" id="entry_form">
      Name:
      <%= text_field "person", "name", "size" => 20 %>

      Password:
      <%= password_field "person", "password", "maxsize"
      => 20 %>

      Single?:
      <%= check_box "person", "single" %>

      Description:
      <%= text_area "person", "description", "cols" =>
      20 %>

      <input type="submit" value="Save">
      </form>
      ##

      knp jadi ada tampilan form? dimana salah gw?

      please kasi bantuan.... terimakasih...

      ~inung;



      ____________________________________________________________________________________
      Do you Yahoo!?
      Everyone is raving about the all-new Yahoo! Mail beta.
      http://new.mail.yahoo.com
    • Show all 3 messages in this topic