Solved

textarea value

Posted on 2013-12-11
4
406 Views
Last Modified: 2013-12-11
I'm trying to modify some wordpress files and I don't know what the "value" is called within a text area.

The textarea is created with this code:
$this->checkout_fields['order']	= array(
			'order_comments' => array(
				'type' => 'textarea',
				'class' => array('notes'),
				'label' => __( 'Order Notes', 'woocommerce' ),
				'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
				)
			);

		$this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields );

		do_action( 'woocommerce_checkout_init', $this );

Open in new window


I need to put a value of a variable in that textarea.  I tried the following code but it does nothing.
$this->checkout_fields['order']	= array(
			'order_comments' => array(
				'type' => 'textarea',
				'class' => array('notes'),
				'label' => __( 'Order Notes', 'woocommerce' ),
				'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
                'value' => $giftmsg
				)
			);

		$this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields );

		do_action( 'woocommerce_checkout_init', $this );

Open in new window

0
Comment
Question by:N R
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39712015
The "value" might actually be working.  Try removing the placeholder or replacing the contents of the placeholder string with the $giftmsg variable.  You will want to use double quotes to get variable substitution.
0
 
LVL 11

Author Comment

by:N R
ID: 39712025
If I put the variable in the contents of the placeholder my $giftmsg does show up so I know the variable is being populated.  But I need it to be the value of the field not just a placeholder.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39712032
I think you might want to try 'default' instead of value:

$this->checkout_fields['order']	= array(
   'order_comments' => array(
      'type' => 'textarea',
      'class' => array('notes'),
      'label' => __( 'Order Notes', 'woocommerce' ),
      'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce'),
      'default' => $giftmsg
   )
);

Open in new window

You also have a comma missing after your 'placeholder' key
0
 
LVL 11

Author Closing Comment

by:N R
ID: 39712041
Yeah, default did it thanks!
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question