Showing posts with label forms. Show all posts
Showing posts with label forms. Show all posts

Monday, March 12, 2012

Form Helper

When using the Form helper to create a form, there are some options you can utilize to make your forms better.

Radio

The following form radio selection is named 'Radio name' and lists two options, 'label1' and 'label2', with 'label1' selected by default.
echo $this->Form->input('Radio name', array('type' => 'radio', 'legend' => false, 'options' => array('value1' => 'label1', 'value2' => 'label2'), 'default' => 'value1')); 

Selection

The following form selection displays a select box with 4 directions and their corresponding single letter values and includes an empty first selection and a default selection of West.
$dirs = array('N' => 'North', 'E' => 'East', 'S' => 'South', 'W' => 'West');
echo $this->Form->input('street_dir', array('label' => __('Direction', true), 'type' => 'select', 'options' => $dirs, 'empty' => true, 'default' => 'W'));

Wednesday, November 10, 2010

Form Focus

One thing I find annoying on web pages is when there is a form you are expected to fill out, such as a login form, and the focus is not on the first field.

Edit /app/views/users/login.ctp and add to the bottom of the page:
<script type="text/javascript">
document.getElementById('UserUsername').focus() 
</script>
Save and upload the file then browse to http://drug-ed.com/users/login and verify the username field has focus.