textarea

A Play Framework data entry form example

Table of Contents1 - Define the routes2 - Create a controller3 - Create the template/form4 - What the form looks like5 - Play form input helpers6 - Form resources

If you’d like an example of how to create a data entry form using the Play Framework v2.6, here’s a complete example.

Sencha Touch textareafield height solutions

Sencha Touch seems to have some problems with its textareafield, especially with sizing and resizing the height in a form. The best solutions I’ve found so far are:

Play Framework forms: specifying @textarea rows and columns

To specify the rows and columns in a Play Framework 2.1.x form field, use a syntax like this:

@textarea(
    urlForm("notes"), 
    '_label -> "Notes",
    'placeholder -> "Any notes you want to add",
    'rows -> 5,
    'cols -> 60
)

The textarea documentation shows that you can also specify the textarea size like this:

jQuery - Create a textarea, insert text into a textarea

jQuery FAQ: How do you create a textarea using jQuery? Also, how do I insert content (text or HTML) into a textarea with jQuery?

I don't know if this will make any sense without showing my HTML, but I just used the following jQuery code to (a) get contents from a specific div tag, (b) add a textarea just before that div, (c) put the HTML contents into the new textarea, then (d) remove the original div. So, in essence, I created a new textarea with jQuery and inserted HTML into that textarea, but I got the HTML from my original div.

The Drupal form field required syntax

Drupal form fields FAQ: What is the syntax to make a Drupal form field (textfield, textarea, password field) required?

To make a Drupal form field required, just use the Drupal form #required attribute, as shown in this required textfield example:

$form['first_name'] = array(
  '#title' => t('First Name'),
  '#type' => 'textfield',
  '#required' => TRUE,
);

As you can see, to set a Drupal form field to be required, you just need to add the #required form attribute, and set it to TRUE.

 

A Drupal form textarea example

Drupal textarea FAQ: How do I create an HTML textarea in a Drupal form (Drupal 6 or Drupal 7)?

Assuming that you're comfortable with creating a Drupal form, you can create a Drupal form textarea as easily as this:

# an html textarea for our drupal form
$form['life_story'] = array(
  '#title' => t('Your Life Story'),
  '#type' => 'textarea',
);

That code creates an HTML textarea with the label "Your Life Story". The textarea is specified with this option in your form declaration:

A Java text area with a background image (watermark image)

Java image FAQ: How can I place an image in the background of a Java text component, such as creating a background image for a JTextArea, JTextPane, or JEditorPane? (i.e., How do I create a Java background or watermark image.)