CI helper
發表於 : 2012-08-07 23:38:03
這是用在 view
要先載入後才可以使用
用法
要先載入後才可以使用
代碼: 選擇全部
$this->load->helper('form');
$this->load->helper('html');
代碼: 選擇全部
echo doctype();
$meta = array(
array('name' => 'robots', 'content' => 'no-cache'),
array('name' => 'description', 'content' => 'My Great Site'),
array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),
array('name' => 'robots', 'content' => 'no-cache'),
array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
);
echo meta($meta);
代碼: 選擇全部
echo form_open('age/add',array('class' => 'email', 'id' => 'myform'),array('hidden1a' => 'Joe', 'hidden1b' => '234'));
echo form_hidden('hidden2','yehlu');
echo form_hidden(array(
'hidden3a' => 'John Doe',
'hidden3b' => 'john@example.com',
'hidden3c' => 'http://example.com'
));
echo form_input(array(
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'maxlength' => '100',
'size' => '50',
'style' => 'width:30'
),
'onClick="some_function()"'
);
echo form_password(array(
'name' => 'username1',
'id' => 'username1',
'value' => 'johndoe',
'maxlength' => '100',
'size' => '50',
'style' => 'width:30'
),
'onClick="some_function()"'
);
echo form_upload(array(
'name' => 'username2',
'id' => 'username2',
'value' => 'johndoe',
'maxlength' => '100',
'size' => '50',
'style' => 'width:30'
),
'onClick="some_function()"'
);
echo form_textarea(array(
'name' => 'username2',
'id' => 'username2',
'value' => 'johndoe',
'cols' => '100',
'rows' => '5',
'style' => 'width:30'
),
'onClick="some_function()"'
);
echo '<hr>';
$options = array(
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
$shirts_on_sale = array('small', 'large');
echo form_dropdown('shirts', $options, 'large');
echo form_dropdown('shirts', $options, $shirts_on_sale);
echo '<hr>';
echo form_multiselect('shirts', $options, 'large');
echo form_multiselect('shirts', $options, $shirts_on_sale);
echo '<hr>';
echo form_fieldset('Address Information');
echo "<p>fieldset content here</p>\n";
echo form_fieldset_close();
$attributes = array('id' => 'address_info', 'class' => 'address_info');
echo form_fieldset('Address Information', $attributes);
echo "<p>fieldset content here</p>\n";
echo form_fieldset_close();
echo '<hr>';
echo form_checkbox('checkbox1', 'accept', TRUE);
$data = array(
'name' => 'checkbox2',
'id' => 'checkbox2',
'value' => 'accept',
'checked' => TRUE,
'style' => 'margin:10px',
);
echo form_checkbox($data);
$js = 'onClick="alert(\'go\')"';
echo form_checkbox('checkbox3', 'accept', TRUE, $js);
echo '<hr>';
echo 'sex';
echo form_radio('radio1', 'M', TRUE).'M';
echo form_radio('radio1', 'F').'F';
$data = array(
'name' => 'radio2',
'id' => 'radio2',
'value' => 'accept',
'checked' => TRUE,
'style' => 'margin:10px',
);
echo form_radio($data);
$js = 'onClick="alert(\'go\')"';
echo form_radio('radio3', 'accept', TRUE, $js);
echo '<hr>';
echo form_label('sex');
$attributes = array(
'class' => 'mycustomclass',
'style' => 'color: #000;',
);
echo form_label('What is your Name', 'username', $attributes);
echo '<hr>';
echo form_reset('reset','reset1');
echo form_button('btn','btn1');
$data = array(
'name' => 'button',
'id' => 'button',
'value' => 'true',
'type' => 'reset',
'content' => 'Reset'
);
echo form_button($data);
$js = 'onClick="alert(\'onClick\')"';
echo form_button('mybutton', 'Click Me', $js);
echo form_submit('mysubmit', 'Submit Post!');
echo form_close();