Hi Matt,
Thanx for your quick response, appreciate it!
I now have the following working:
%label INLAEGG:
%br
%textarea{:name => "inlaegg", :id => "inlaegg"}
#{@book_mark.inlaegg}
I first tried the following, which seems logical: %textarea{:name =>
"inlaegg", :id => "inlaegg", :value => "#{@book_markinlaegg}"}
This allows me to write text in the text field and save it successfully to
the DB, but it doesn't show the text when I open the view.
Just wanted to point it out. Thanx again!
On Sunday, February 10, 2013 10:54:39 AM UTC-8, Matt Wildig wrote:
>
>
> On 10 Feb 2013, at 17:58, Lennart Frantzell wrote:
>
> >
> > Since HAML currently doesn't seem to support text areas, I am using the
> > following workaround: ~ "<textarea>#{@book_mark.inlaegg}</textarea>"
> > Which does indeed bring up a textarea with text from the model.
> >
>
> <textarea> is just another HTML tag. You can create them in Haml like:
>
> %textarea{:name => 'control_name'}
> Initial content here
>
> > The only problem is that the text does not get saved. with the following
> > model code:
> > post '/bookmarks/' do
> > inlaegg = params[:inlaegg]
> > etc...
> >
> > Don't I need to add additional metadata to the textarea in my view,
> along
> > the lines of: %input{:type => "textarea", :name => "inlaegg", :id =>
> > "inlaegg", :value => "#{@book_mark.inlaegg}"}
> >
>
> You need to specify a `name` attribute for the textarea. See above for an
> example.
>
> > How do I do this, given that I have to use the ~
> > "<textarea>#{@book_mark.inlaegg}</textarea>" construct in HAML?
> >
>
> In plain HTML like this, you would just do
>
> <textarea name='inlaegg'> ...
>
> Here's a simple complete example that might help:
>
> require 'sinatra'
> require 'haml'
>
> get '/' do
> haml :index
> end
>
> __END__
>
> @@index
>
> %pre
> = params['data']
>
> %form{:method => 'get', :action => '/'}
> %textarea{:name => 'data'}
> %input{:type => 'submit'}
>
> Hope this helps.
>
> Matt
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/haml?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.