Image field in edit mode still asking for image as a 'required' field - laravel-5.6

In the voyager backend, i set an image field as required in the BREAD section:
This works well in 'add' mode. image field will be validated if empty
Issue occurs in 'edit' mode. The image appears but on clicking on 'save', a prompt is thrown indicating the image field is empty(therefore requiring the image to be uploaded again):
therefore getting an 'Image field is required' prompt on edit. this appears to be a bug. Anyone experienced this issue and how did you fix it?

Found a solution from the ticket i had raised on Voyager's github's page:
i.e. using required_if instead of required
{ "validation": { "rule": "required_if:id,null", "messages": { "required": "your message" } } }
here's the ticket:
Voyager image edit issue

You can just set the rule on the column to the following
{
"rule": "nullable"
}

Related

how to translate the result not found message of a select2 with laravel

I have a problem with the translation of select2 which is filled via an ajax call. I would like to translate the text result not found. If someone can help me it will be really nice.
You can customize not found text using property noResults
Example of code
{
"language": {
"noResults": function(){
return "My custom No Results Found";
}
},

Create a non-editable field in Strapi

I have a project that sells products.
A product can have a price and optional: new_price. I would like to be able to sort them by price/new_price combined, meaning that I would need an additional entry in the DB like "final_price". I got an idea to create a non-editable field "new_price" in Content-Type Builder/schema.json and then update that with the final price for the product on "beforeCreate" in the lifecycles.js. However, I am not sure Strapi allows that, as I haven't been able to find a resource pointing in the documentation that it can. If there is a hacky way to do it, please advise. I am open to all kinds of other suggestions on how to do this Business logic as well.
Thank you in advance.
There is a way in strapi to make the field non editable on UI. You can go to Content-type-builder-> Your component-> Configure the view. And click on the text field. You can just make editable field as false.
I see two options:
(a) Add the field and forget about it being non-editable. You can calculate the final_price on insertion of an entry in your collection with Lifecycle hooks: https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#lifecycle-hooks.
(b) Don't add a new field, but override the controller to return an additional field: https://docs.strapi.io/developer-docs/latest/development/backend-customization/controllers.html#extending-core-controllers.
Ok, so I found a "hacky" way to do this. I don't like it, as it is not that beautiful and sophisticated, but it does the job.
In product schema.json I added a
"final_price": {
"type": "decimal"
}
In lifecycles.js, I created a new function that will calculate my final price and write it in "final_price" attribute:
module.exports = {
beforeCreate(event) {
priceCalc(event);
},
beforeUpdate(event) {
priceCalc(event);
},
};
const priceCalc = (event) => {
const { data } = event.params;
data.final_price = data.new_price ? data.new_price : data.price;
};
In the admin panel, in Content-Type Builder in Product, I clicked "Configure the view" and deleted the Final Price field from Displayed Fields section. This made the field hidden, lol.
Now I am sorting all products with sort: ['final_price:asc']
That is it.Hope it helps anyone!

Wix Code filter not working

Im new to wix code. I created a simple database with a title field and some other fields as a test.
I created a text edit box so i can type in a search text, and a grid object so i can see the results.
I connect the grid to the data base and all the fields such as image, description etc.
Then i run the preview mode without typing anything, the grid shows all the table elements.
When i type into the search, even if i type something that is in the table, the grid is blank, seems the filter doesnt work??
Anybody knows why???
here is my code attached to the page
import wixData from "wix-data"
$w.onReady(function () {
});
export function iAddress_keyPress(event, $w) {
filter($w('#iAddress').value); // iAddress is the name of the input text box
}
function filter(title) {
$w('#dataset1').setFilter(wixData.filter().contains('Title',title));
}
Simple. This is problem:
contains('Title',title)
Title - it's "name" of the column. You should use "field name" from collection, it's displayed when you press "manage properties" on some column - it's actually id.
In your case, "title" is correct field name (as it's default)
Your example will work with this:
contains('title',title)

How to prevent Kendo Grid click propagation

I need to add an image to one specific column, so I have something like that, This is good, I see the image, I just added am alert to see how is working. My problem is that after showing the alert, is executing the sorting. Is there a way to avoid the sorting when I just click on my image?
{
field: "ShipName", headerTemplate: "<a class='k-link pull-left' href='#'>Charge</a><img onclick='alert(1)' src='http://localhost/MyApp/images/Reports/filterApplied.png' title='this is a filter'/>",
title: "Ship Name"
}
If you do not want that particular column to sort, then disable it in your grid's configuration. API Reference.
Try adding return false;, which works like e.preventDefault():
onclick='alert(1); return false;'

extjs show validation when switching tabs

HI,
I hope somebody can help me here with the extjs framework.
The problem I am having is that the field validation is not being rendered for the tabs that are not visibele on initialisation off the panel.
It only starts working when clicking in the textfields.
What I need is something to force the validation cue's for the fields on activating the tabs.
EDIT
I came up with this
Ext.getCmp('aanMakenGebruikerTabPanel').on('tabchange',function(){
AanMakenGebruikerWindow.syncShadow();
Ext.getCmp('Mobiel1Veld').on('render',function(v){v.validate();});
Ext.getCmp('Email1Veld').on('render',function(v){v.validate();});
//console.log("[aanMakenGebruikerTabPanel] resize -- sync");
});
EDIT
I SOLVED IT BY USING THE CASCADE FUNCTION SO IT ALSO REACHES ITEMS IN A FIELDSET.
Ext.getCmp('aanMakenGebruikerTabPanel').on('tabchange',function(tabPanel,tab){
AanMakenGebruikerWindow.syncShadow();
tab.cascade(function(item) {
if (item.isFormField) {
item.validate();
}
} );
});
thanks, Richard
The deferredRender option defaults to true. Will setting it to false help?
{
xtype: 'tabpanel',
deferredRender: false,
items: []
}
In your Tab Panel config object add listeners for the beforetabchange/tabchange event. In the handler you have to iterate through the fields contained in the activated tab and trigger each field's validation. Hope this helps.

Resources