How to save data from custom field. In above image i already create some custom field. After fill and close dialog not save value. I have no idea why.
How to fix it
Please publish the HTML markup for your custom field.
template same in vendor\magento\module-product-video\view\adminhtml\templates\helper\gallery.phtml
I just added more fields to dialog-template associated with image
<div class="field">
<label class="label"><?php echo __('Item Title') ?></label>
<div class="control">
<input type="text" name="banner[media_gallery][images][<%- data.file_id %>][item_title]" />
</div>
</div>
<div class="field field-item-alt">
<label class="label"><?php echo __('Item Image Alt') ?></label>
<div class="control">
<input type="text" name="banner[media_gallery][images][<%- data.file_id %>][item_alt]" />
</div>
</div>
<div class="field field-item-url">
<label class="label"><?php echo __('Item Url') ?></label>
<div class="control">
<input type="text" name="banner[media_gallery][images][<%- data.file_id %>][item_url]" />
</div>
</div>
<div class="field field-item-short-description">
<label class="label"><?php echo __('Item Short Description') ?></label>
<div class="control">
<textarea rows="3" name="banner[media_gallery][images][<%- data.file_id %>][item_short_description]"></textarea>
</div>
</div>
<div class="field field-item-status">
<label class="label"><?php echo __('Item Status') ?></label>
<div class="control">
<select class="item_select select" name="banner[media_gallery][images][<%- data.file_id %>][item_status]">
<option value="1"><?php echo __('Enable') ?></option>
<option value="0"><?php echo __('Disable') ?></option>
</select>
</div>
</div>
How to save data all field above after fill all input
How is this markup related to the screenshot above?
Is the server part successfully receive the custom inputs’ values?
No. Magento not save data that i fill in. How it can save it. Because after i close dialog. Values were gone.
My archievement is going to want save data i just put in input. This dialog is a part of form. I need data for save form after
The form you are trying to modify is not a plain HTML form, it is a text/x-magento-template
:
So you should place your input fields inside the same text/x-magento-template
.
Thanks, i will try it again
<%- data.item_short_description %> this custom var of mine not work
Where in code i can find all variables? Magento use this var <%- data.label %> <%- data.url %> in dialog
Please publish the exact link to the problem Magento 2 code block in the GitHub.
Anyone found the solution? I have post question on stack-exchange.
https://magento.stackexchange.com/questions/264398/magento-2-admin-product-image-detail-custom-textfield-value-gone-after-dialog-cl
Also have this situation, i haven’t idea how can i save value and in which table if i add some new field in this popup