Powered by SmartDoc

Form

CKForm

Creates a fill-in form. Dynamic Elements of form, for example, CKBrowser, CKCheckbox, CKRadioButton, CKPopUpButton, CKText, CKTextField, CKSubmitButton and CKResetButton, are used within CKForm or HTML form. Required attributes are none.

To upload files with form, set enctype attribute to ?multipart/form-data? or fileupload attribute to true. Even if you set multipart form, form data is processed as String excepted data setted content type. The data is used by CKFileUpload as CKByteData.

Attributes of CKForm
Attribute Type Description
method String Method to send form data. You can use POST, GET or HEAD as the value.
enctype String Method to encode form data. Set "multipart/form-data" to this attribute when using CKFileUpload.
href String URL to which the browser directs.
target String Frame in a frameset that receive the page.
query Hash Hash as the query string. The value of queryattribute is converted to string. Then, the string is added to append the URL.
fileupload true/false If you set this attribute to true, enctypeattribute is setted to "multipart/form-data". You can use this instead of enctypewhen using CKFileUpload.

CKTextField

Creates a text input field. This element must be used within CKForm or HTML form.

Required attribute: value

Attributes of CKTextField
Attribute Type Description
type String Type of the text field. textis for a normal text input field, passwordis for a password field and hiddenis for a hidden field.
value String Value of the text field. If you set an accessor method to this element, the form data is set to a component automatically by the method.
size Integer Size of the text field.
maxlength Integer Max length of data for the text field.
validate String Format string to validate input value.
pass true/false If validating is passed, the value is true.
enabled true/false If the value is false, the element appears but is not active.

CKText

Creates a text area. This element must be used within CKForm or HTML form.

Required attribute: value

Attributes of CKText
Attribute Type Description
value String Value of the text area.
columns Integer Column size.
rows Integer Row size.
validate String Format string to validate input value.
pass true/false If validating is passed, the value is true.
enabled true/false If the value is false, the element appears but is not active.

CKCheckbox

Creates a checkbox. This element must be used within CKForm or HTML form.

Required attributes: selectionand value, or checked

Attributes of CKCheckbox
Attribute Type Description
checked true/false If neither valuenor selectionattribute is nil and the value of selectionis equal to that of value, the check box is checked.
value String When the check box is checked, the value of valueattribute is set to the component by the method specified by selectionattribute.
selection Array Object that the user chose from the check box.
enabled true/false If the value is false, the element appears but is not active.

You use this element in two ways. One it the way to use checkedattribute. The other is the way to use both selectionand valueattributes.

checked attribute

If you use checkboxes with checkedattribute, the checkboxes are controlled with on/off.

<cgikit name=Form>
<cgikit name=Checkbox1>One</cgikit>
<cgikit name=Checkbox2>Two</cgikit>
<cgikit name=Checkbox3>Three</cgikit>
<cgikit name=Submit/>
</cgikit>
Form : CKForm {
}

Checkbox1 : CKCheckbox {
  checked = checkedOne;
}

Checkbox2 : CKCheckbox {
  checked = checkedTwo;
}

Checkbox3 : CKCheckbox {
  checked = checkedThree;
}

Submit : CKSubmitButton {
}
class Checkbox < CKComponent
  attr_accessor :checkedOne, :checkedTwo, :checkedThree
end

The variables are substituted true when the checkboxes clicked.

value and selection attributes

Another usage of CKCheckbox is combination with selectionand valueattributes. selectionattribute is substituted value of valueattribute when a checkbox clicked. Checkboxes turn on if values of selectionand valueattributes are equal.

<cgikit name=Form>
<cgikit name=Checkbox1>One</cgikit>
<cgikit name=Checkbox2>Two</cgikit>
<cgikit name=Checkbox3>Three</cgikit>
<cgikit name=Submit></cgikit>
</cgikit>
Form : CKForm {
}

Checkbox1 : CKCheckbox {
  value = "One";
  selection = checkedOne;
}

Checkbox2 : CKCheckbox {
  value = "Two";
  selection = checkedTwo;
}

Checkbox3 : CKCheckbox {
  value = "Three";
  selection = checkedThree;
}

Submit : CKSubmitButton {
}
class Checkbox < CKComponent
  attr_accessor :checkedOne, :checkedTwo, :checkedThree
end

CKRadioButton

Creates a radio button. This element must be used within CKForm or HTML form.

Required attributes: selectionand value, or checked

Attributes of CKRadioButton
Attribute Type Description
name String Name that identifies the radio button's group.
checked true/false If neither valuenor selectionattribute is nil and the value of selectionis equal to that of value, the check box is checked.
value String When the check box is checked, the value of valueattribute is set to the component by the method specified by selectionattribute.
selection String Object that the user chose from the check box.
enabled true/false If the value is false, the element appears but is not active.

This is a sample with checkedattribute.

<cgikit name=Form>
<cgikit name=Radio1>One</cgikit>
<cgikit name=Radio2>Two</cgikit>
<cgikit name=Radio3>Three</cgikit>
<cgikit name=Submit></cgikit>
</cgikit>
Form : CKForm {
}

Radio1 : CKCheckbox {
  name = "radio";
  checked = checkedOneTwoThree;
}

Radio2 : CKCheckbox {
  name = "radio";
  checked = checkedOneTwoThree;
}

Radio3 : CKCheckbox {
  name = "radio";
  checked = checkedOneTwoThree;
}

Submit : CKSubmitButton {
}
class Checkbox < CKComponent
??_??_attr_accessor :checkedOneTwoThree
end

CKPopUpButton

Creates a pop-up menu. This element must be used within CKForm or HTML form.

Required attribute: list

Attributes of CKPopUpButton
Attribute Type Description
escape true/false Escapes HTML control characters in the items of the list if the escapeis true. The default value is true.
list Enumerable Array which is iterated through.
default String The first item if no item is selected.
selected String Item that are chosen from the selection list.
values Array Array which is value for each valueattributes of <option>elements.
enabled true/false If the value is false, the element appears but is not active.

CKBrowser

Creates a list whose multiple items can be selected. This element must be used within CKForm or HTML form.

Required attribute: list

Attributes of CKBrowser
Attribute Type Description
escape true/false Escapes HTML control characters in the items of the list if the escapeis true. The default value is true.
list Enumerable Array which is iterated through.
selected Array Items which are chosen from the list.
values Array Array which is value for each valueattributes of <option>elements.
multiple true/false Multiple items of the list can be selected if the value is true.
size Integer Size of item in appearance.
enabled true/false If the value is false, the element appears but is not active.

CKSubmitButton

Creates a submit button. This element must be used within HTML form. Required attributes are none.

Attributes of CKSubmitButton
Attribute Type Description
action CKComponent Method to invoke when the button is clicked.
value String Title of the button.
enabled true/false If the value is false, the element appears but is not active. In addition, it doesn't send the form data although the button is clicked.

CKResetButton

Creates a reset button. This element must be used within CKForm or HTML form. Required attributes are none.

Attributes of CKResetButton
Attribute Type Description
value String Title of the button.

CKFileUpload

CKFileUpload generates an input form to upload files. To use this, set enctypeattribute of CKForm to "multipart/form-data".

Required attributes: dataand file

Attributes of CKFileUpload
Attribute Type Description
data CKByteData Variable of the attribute is set the uploaded file as a CKByteData object.
file String Path of the uploaded file.
enabled true/false If the value is false, the element appears but is not active.