Cuisine comes with a lot of field-types build in. Here’s a list:
Text
A regular text-input.
Field::text( 'name', 'Label', $args )->render();
Textarea
A textarea field. **Aditional arguments: ** Row ( pass the amount of rows this textarea needs)
Field::textarea( 'name', 'Label', $args )->render();
Date
A date-field using jQuery-ui’s datepicker.
Field::date( 'name', 'Label', $args )->render();
Number
A html5 number-field. Auto-validates ‘is-number’
Field::number( 'name', 'Label', $args )->render();
A html5 email-field. Auto-validates e-mailadresses
Field::email( 'name', 'Label', $args )->render();
Checkbox
Creates a single checkbox. Returns true or false as a string.
Field::checkbox( 'name', 'Label', $args )->render();
Checkboxes
Multiple checkboxes. Pass options as the third argument.
$options = array( 'option-one' => 'Option One', // value - label 'option-two' => 'Option Two', 'option-etc' => 'Etc.' ); Field::checkboxes( 'name', 'Label', $options, $args )->render();
Radio buttons
Multiple radio-buttons. Pass options as the third argument.
$options = array( 'option-one' => 'Option One', // value - label 'option-two' => 'Option Two', 'option-etc' => 'Etc.' ); Field::radio( 'name', 'Label', $options, $args )->render();
Select box
A select-dropdown. Pass options as the third argument.
$options = array( 'option-one' => 'Option One', // value - label 'option-two' => 'Option Two', 'option-etc' => 'Etc.' ); Field::select( 'name', 'Label', $options, $args )->render();
Image
Adds a thumbnail of the selected image and a button to edit the image. Opens the WordPress media library and > saves the image’s ID, the three default WP-sizes and some meta-information. Currently only works in the > WordPress admin.
Field::image( 'name', 'Label', $args )->render();
Media
Adds a gallery where multiple images, videos and other media can be saved. Items can be ordered by drag & drop. This saves the media-item’s ID, position and thumb-url.
Field::media( 'name', 'Label', $args )->render();
Repeater field
Similar to Advanced custom fields repeater-fields. Creates a layout that can be repeated indefinitely. Takes an array of Field objects as it’s third parameter.
$fields = array( Field::text( 'title', 'Title' ), Field::date( 'date', 'Date' ) ); Field::repeater( 'name', 'Label', $fields, $args )->render();
Flex field
Similar to Advanced custom fields flexible-layout-fields. Creates multiple layouts that can be repeated indefinitely. Takes an array of layouts (which is just an array of Field objects ) as it’s third parameter.
$layouts = array( 'button' => [ 'layout' => 'button', 'label' => __( 'Button' ), 'fields' => [ Field::text( 'title', __( 'Title' ) ), Field::text( 'button_text', __( 'Click here' ) ), ] ], 'textblock' => [ 'layout' => 'textblock', 'label' => __( 'Tekst block' ), 'fields' => [ Field::title( 'title', __( 'Title' ) ), Field::editor( 'textarea', __( 'Content' ) ) ] ] ); Field::flex( 'button_or_text', 'Label', $layouts, $args )->render();