Selasa, 13 Julai 2010

CakePHP 1.3 Form Samples with default values


These are form examples with default value for CakePHP 1.3

Pastebin source code : http://pastebin.com/MAekWJCt



create('Post', array(
'url' => '/posts/index',
'type' => 'file',  
));

echo $form->input('text', array(
'type' =>'text',
'value' => 'default value',
));
echo $form->input('textarea', array(
'type' =>'textarea',
'value' => 'default value',
));

$options = array(
'1' => 'Option 1', 
'2' => 'Option 2',
'3' => 'Option 3',
);
echo $form->input('select', array(
'type' =>'select', 
'options' => $options,
'selected' => 2,
'empty' => 'Please Select'
));


echo $form->input('multiple_select', array(
'type' =>'select', 
'options' => $options,
'selected' => 2,
'empty' => 'Please Select Multiple',
'multiple' => true
));


echo $form->input('checkbox', array(
'type' =>'select',
'multiple'=> 'checkbox',         
'options' => $options,
'selected' => 2,
));

echo $form->input('radio', array(
'type' =>'radio',
'options' => $options,
'legend' => 'Radio',
'default' => '2'

));
?>

CheckBoxes input('checkbox2', array( 'type' => 'checkbox', 'value' =>'1', 'checked' => 'checked', 'label' => 'Choice 1' )); echo $form->input('checkbox2', array( 'type' => 'checkbox', 'value' =>'2', 'label' => 'Choice 2' )); ?>
input('file', array( 'type' => 'file', 'label' => 'Browse File' )); echo $form->input('date', array( 'type' => 'date', 'label' => 'Date', 'minYear' => 1900, 'maxYear' => 2010, # default order m/d/y 'selected' => array( 'month' => '03', 'day' => '09', 'year' => '1977' ), )); echo $form->input('time', array( 'type' => 'time', 'label' => 'Time', 'selected' => array( 'hour' => '12', 'min' => '15', 'meridian' => 'pm' ), )); echo $form->input('datetime', array( 'type' => 'datetime', 'label' => 'Date Time', 'minYear' => 1900, 'maxYear' => 2010, # default order m/d/y 'selected' => array( 'month' => '03', 'day' => '09', 'year' => '1977', 'hour' => '13', 'min' => '10', 'meridian' => 'am' ), )); echo $form->submit('Submit'); echo $form->end(); ?>

4 ulasan:

  1. terimakasih bro...sangat2 bermanfaat

    BalasPadam
  2. Thank you very much for the code.

    BalasPadam
  3. Thank you so much for sharing this kind of Knowledge with us..Cake PHP Development blog..

    BalasPadam