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

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

Expand Messages
  • ~inung;
    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
    Message 1 of 3 , 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
    • ~inung;
      ralat, sudah ketemu ding... ternyata kurang = di save }, ...
      Message 2 of 3 , Dec 1, 2006
      • 0 Attachment
        ralat, sudah ketemu ding... ternyata kurang "=" di
        <%= start_form_tag ({:action=>"save"},
        :id=>"entry_form")%>
        <%= text_field :entry, :title %><br />
        <%= text_area :entry, :body%><br />
        <%= submit_tag "Save" %>
        <%= end_form_tag %>

        :D sounds so silly....:D
        ~inung;

        --- "~inung;" <inoeng_satriani@...> wrote:

        > 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
        >




        ____________________________________________________________________________________
        Do you Yahoo!?
        Everyone is raving about the all-new Yahoo! Mail beta.
        http://new.mail.yahoo.com
      • Arie Kusuma Atmaja
        ... sekedar mengingatkan... bentar lagi Rails 1.2 pakai wrapper ... -- Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM! = riyari3
        Message 3 of 3 , Dec 5, 2006
        • 0 Attachment
          ~inung; wrote:
          > ralat, sudah ketemu ding... ternyata kurang "=" di
          > <%= start_form_tag ({:action=>"save"},
          > :id=>"entry_form")%>

          sekedar mengingatkan... bentar lagi Rails 1.2 pakai wrapper
          <% form_for %>
          <% end %>

          > <%= text_field :entry, :title %><br />
          > <%= text_area :entry, :body%><br />
          > <%= submit_tag "Save" %>
          > <%= end_form_tag %>
          >
          > :D sounds so silly....:D
          > ~inung;

          --
          Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM! = riyari3
          http://ariekusumaatmaja.wordpress.com http://groups.yahoo.com/groups/id-ruby
          http://groups-beta.google.com/group/id-jp # 日本語を勉強しましょう
          http://groups-beta.google.com/group/id-fr # parlons français
        Your message has been successfully submitted and would be delivered to recipients shortly.