?
Solved

textarea value

Posted on 2013-12-11
4
Medium Priority
?
410 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:Nathan Riley
[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 111

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 12

Author Comment

by:Nathan Riley
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 44

Accepted Solution

by:
Chris Stanyon earned 2000 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 12

Author Closing Comment

by:Nathan Riley
ID: 39712041
Yeah, default did it thanks!
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 …
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

649 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