Fields¶
Here’s an example of the method “getAvailableFields”
class MyEndpoint implements \Infonique\Newt\NewtApi\EndpointInterface
{
public function getAvailableFields(): array
{
$istopnews = new Field();
$istopnews->setName("istopnews");
$istopnews->setLabel("Top News");
$istopnews->setType(FieldType::CHECKBOX); // Field CHECKBOX
$title = new Field();
$title->setName("title");
$title->setLabel("Title");
$title->setType(FieldType::TEXT); // Field TEXT
$image = new Field();
$image->setName("image");
$image->setLabel("Image");
$image->setType(FieldType::IMAGE); // Field IMAGE
return [
$istopnews,
$title,
$image,
];
}
}
As you can see, you define your fields and then return theme as an array.
Here are all current available field-types:
TEXT¶
Simple Text-Field, single line
$text = new Field();
$text->setName("text");
$text->setLabel("Text");
$text->setType(FieldType::TEXT);
Return value: | String |
---|
INTEGER¶
Field to enter a number (no text)
$integer = new Field();
$integer->setName("integer");
$integer->setLabel("Integer");
$integer->setType(FieldType::INTEGER);
Return value: | Integer as String |
---|
DECIMAL¶
Field to enter a decimal (no text)
$decimal = new Field();
$decimal->setName("decimal");
$decimal->setLabel("Decimal");
$decimal->setType(FieldType::DECIMAL);
Return value: | Float as String |
---|
PASSWORD¶
Works like any other password-field
$password = new Field();
$password->setName("password");
$password->setLabel("Password");
$password->setType(FieldType::PASSWORD);
Return value: | String |
---|
TEXTAREA¶
Multiline text-area
$textarea = new Field();
$textarea->setName("textarea");
$textarea->setLabel("Textarea");
$textarea->setType(FieldType::TEXTAREA);
Return value: | String |
---|
HTML¶
RichEditor for html-text
$textarea = new Field();
$textarea->setName("html");
$textarea->setLabel("HTML");
$textarea->setType(FieldType::HTML);
Return value: | String |
---|
CHECKBOX¶
A checkbox to select on/off values
$checkbox = new Field();
$checkbox->setName("checkbox");
$checkbox->setLabel("Checkbox");
$checkbox->setType(FieldType::CHECKBOX);
Return value: | String (1=on / 0=off) |
---|
DATE¶
Date picker to chose from a mini-calendar
$date = new Field();
$date->setName("date");
$date->setLabel("Date");
$date->setType(FieldType::DATE);
Return value: | String (eg.: 2022-03-05) |
---|
TIME¶
Time picker to chose a time
$time = new Field();
$time->setName("time");
$time->setLabel("Time");
$time->setType(FieldType::TIME);
Return value: | String (eg.: 21:12) |
---|
DATETIME¶
Combined Date-Time picker
$datetime = new Field();
$datetime->setName("datetime");
$datetime->setLabel("Datetime");
$datetime->setType(FieldType::DATETIME);
Return value: | String (eg.: 2022-03-05 21:12) |
---|
SELECT¶
Select a velue from a list
$select = new Field();
$select->setName("select");
$select->setLabel("Select");
$select->setType(FieldType::SELECT);
foreach (["Option 1", "Option 2", "Option 3"] as $key => $val) {
$item = new FieldItem($key, $val);
$select->addItem($item);
}
Return value: | String |
---|
LABEL¶
Will only display a label, you can use this field for hints
$label = new Field();
$label->setName("label");
$label->setLabel("Label");
$label->setType(FieldType::LABEL);
Return value: | none |
---|
DIVIDER¶
Will show a divider
$divider = new Field();
$divider->setType(FieldType::DIVIDER);
Return value: | none |
---|
IMAGE¶
Te image-picker can be triggered from gallery or from the camera
$image = new Field();
$image->setName("image");
$image->setLabel("Image");
$image->setType(FieldType::IMAGE);
Return value: | Binary as Base64String |
---|
FILE¶
Add files as attachement
$file = new Field();
$file->setName("file");
$file->setLabel("File");
$file->setType(FieldType::FILE);
Return value: | Binary as Base64String |
---|
BARCODE¶
Scan for barcodes: Code128, Code39, EAN13 or EAN8
$barcode = new Field();
$barcode->setName("barcode");
$barcode->setLabel("Barcode");
$barcode->setType(FieldType::BARCODE);
Return value: | String |
---|
RATING¶
Shows a rating field with an count of stars
$rating = new Field();
$rating->setName("rating");
$rating->setLabel("Rating");
$rating->setType(FieldType::RATING);
$rating->setCount(6); // Count of stars
Return value: | Percentag of the rating as String (all stars = 100% / 1 Star = (100/n)%) |
---|
SIGNATURE¶
The signatur field opens a canvas, to paint on
$signatur = new Field();
$signatur->setName("signatur");
$signatur->setLabel("Signatur");
$signatur->setType(FieldType::SIGNATURE);
Return value: | Binary as Base64String (PNG-Image) |
---|
QRCODE¶
Scan QR-Codes and use the content
$qrcode = new Field();
$qrcode->setName("qrcode");
$qrcode->setLabel("QR-Code");
$qrcode->setType(FieldType::QRCODE);
Return value: | String |
---|
LOCATION¶
Mini-Map to chose the current-location of the user
$location = new Field();
$location->setName("location");
$location->setLabel("Location");
$location->setType(FieldType::LOCATION);
Return value: | String (lat,lng,accuracy) |
---|