2016-09-13, 16:45:55
NOTE: Datepicker field has a little issue, it seems the date can not be selected in admin (API has no issue) for the first time. Just open the field settings for each date picker field and re-save, it should permanently resolve this issue.
About your questions: ItemManager dies not care about HTML (inputs, forms, etc ) or JavaScript and other stuff on the front-end, it simply stores the data and delivers it in raw format to your when required, so you've full control over the whole markup around.
You need to know the following, If you wish to get your data from a specific item, the first thing you must do is to get your item. Therefor you'll need one attribute of your category (an ID for example) and an attribute of your item. Here's only one of the many ways how you can get a single Item:
Next, how you can output the data stored in your item. Let's say that your item has a datepicker field named "date", so you can output the field value as follows:
That's basically all you have to know about the output.
Here is an example how to save data entered into the form field as item field value, if the item already exists and is selected (see example above, how to get an item):
To save date in a new item:
That's all you have to know about save the data.
The code you can put in your template, to put it in the component you can use DynPages plugin.
All other problems relate not to the ItemManager and resulting from other reasons JavaScript issue or something else. If I have time later I'll look at the link you have given.
About your questions: ItemManager dies not care about HTML (inputs, forms, etc ) or JavaScript and other stuff on the front-end, it simply stores the data and delivers it in raw format to your when required, so you've full control over the whole markup around.
You need to know the following, If you wish to get your data from a specific item, the first thing you must do is to get your item. Therefor you'll need one attribute of your category (an ID for example) and an attribute of your item. Here's only one of the many ways how you can get a single Item:
PHP Code:
// Initialize your item in the memory. The first parameter is the category ID and the second an item ID
imanager()->getItemMapper()->limitedInit(9, 469);
// save desired item in $item variable
$item = imanager()->getItemMapper()->getItem(469);
Next, how you can output the data stored in your item. Let's say that your item has a datepicker field named "date", so you can output the field value as follows:
PHP Code:
<form ... >
<input type="text" name="date" value="<?php echo date('Y/m/d', $item->fields->date->value); ?>">
</form>
That's basically all you have to know about the output.
Here is an example how to save data entered into the form field as item field value, if the item already exists and is selected (see example above, how to get an item):
PHP Code:
// Check form is sent
if(!empty($_POST['submit'])) {
// NOTE: the $picked_date must have a valid format: 2016-09-16, 2016/09/17, ...
$picked_date = !empty($_POST['date']) ? $_POST['date'] : '';
$item->setFieldValue('date', $picked_date, true);
$item->save();
}
To save date in a new item:
PHP Code:
// Check form is sent
if(!empty($_POST['submit'])) {
$picked_date = !empty($_POST['date']) ? $_POST['date'] : '';
// Change 9 to your category ID
$item = new Item(9);
$item->name = 'My Date';
$item->active = 1;
$item->setFieldValue('date', $picked_date, true);
$item->save();
}
That's all you have to know about save the data.
The code you can put in your template, to put it in the component you can use DynPages plugin.
All other problems relate not to the ItemManager and resulting from other reasons JavaScript issue or something else. If I have time later I'll look at the link you have given.