Netlify CMS date field is showing a glitch / error - momentjs

My date field in Netlify is showing 08/19/2022 fam8/19/202205. How do I fix that?
My config.yml contains:
- {
label: 'Date',
name: 'date',
widget: 'datetime',
time_format: 'false',
format: 'MM-DD-YYYY',
picker_utc: true,
}
image of the error

The time_format option accepts either a boolean or Moment.js tokens (cf documentation).
In your case, you are giving it a string, which it is trying to interpret as the latter (hence the weird output).
Change it to a boolean (ie: no quotes) and it should work:
- label: 'Date'
name: 'date_test'
widget: 'datetime'
time_format: false
format: 'MM-DD-YYYY'
picker_utc: true

Related

Structural error property type should be equal to one of the allowed values allowedValues: string, number, boolean, integer, array in Swagger editor

I'm using springfox 2.9.2 and want test my swagger JSON as YAML in https://editor.swagger.io/
I have property with #ApiParam annotation type: object
#ApiParam(value = "metadata file")
protected Object metadataFile;
but when I test my generated json on swagger editor I got this error:
Structural error at ---.parameters.5.type should be equal to one of
the allowed values allowedValues: string, number, boolean, integer,
array Jump to line ---
there is way to allowed property type object in this section?
the section that trigger the problem
paths:
:
post:
parameters:
name: metadataFile
in: query
description: ...
required: false
type: object
Swagger documentation (go to the bottom of the page): https://swagger.io/docs/specification/2-0/describing-parameters/
"Can I have an object as a query parameter?
This is possible in OpenAPI 3.0, but not in 2.0."

EasyAdminBundle - Unrecognized option "sort" under "easy_admin.list"

I've been looking for a way to override the default sorting of data which is based on primary key.
I found some configuration examples for sorting data from the documentation but it doesn't work.
It says
Unrecognized option "sort" under "easy_admin.list"
easy_admin:
entities:
Customer:
class: AppBundle\Entity\Customer
list:
sort: 'name'
form:
title: 'Add Customer'
form_options: {validation_groups:['Default']}
fields:
- name
- {property: 'gender', type: 'choice', type_options:
{
placeholder: 'Select your gender',
choices: {
Female: 'female',
Male: 'male'
}
} }
- {property: 'birthdate', type: 'date', type_options: {widget: 'single_text'}}
- isActive
new:
form_options: {validation_groups: ['Default','Customer']}
edit:
title: 'Edit Customer'
site_name: 'Premiere Sales'
You use sort option in the wrong place. You should set sort option under your entity scope of configuration:
easy_admin:
entities:
User:
# ...
list:
# if the sort order is not specified, 'DESC' is used
sort: 'createdAt'
It seems that the configuration I posted above is correct and I just restarted the server and the browser and it works fine

Uploading of image to WordPress through Python's requests

In order to validate the installation of WordPress instances, we are writing Python unit tests. One of the test should perform the following action: upload an image to WordPress.
In order to do that, I am using the Requests library.
When I inspect the form within /wp-admin/media-new.php page through Firebug (form information, I get the following information):
Form
Id: file-form
Name
Method: post
Action: http://localhost:8000/wp-admin/media-new.php
Elements
id: plupload-browse-button
type: button
value: Select Files
id:async-upload
name: async-upload
type: file
label: Upload
id:html-upload
name: html-upload
type: submit
value: Upload
id: post_id
name: post_id
type: hidden
value: 0
id: _wpnonce
name: _wpnonce
type: hidden
value: c0fc3b80bb
id: file-form
name: _wp_http_referer
type: hidden
value: /wp-admin/media-new.php
I believe that the _wpnonce is a unique value generated for each session. Therefore, before trying to upload the file, I get the media-new.php page and grab the _wpnonce in the form (hence the variable in my code).
My code is the following:
with open('1.jpg', 'rb') as f:
upload_data = {'post_id': '0',
'_wp_http_referer': '/wp-admin/media-new.php',
'_wpnonce': wp_nonce,
'action': 'upload_attachement',
'name': '1.jpg',
'async-upload': f,
'html-upload': 'Upload'}
upload_result = session.post('http://localhost:8000/wp-admin/media-new.php', upload_data)
The code runs fine and the upload_result.status_code equals 200.
However, the image never shows up in the media gallery of WordPress.
I believe this a simple error, but I can't figure out what I'm missing.
Thanks in advance for the help.
If you want to post files you should use the files parameter. Also the '_wpnonce' value is not enough to get authenticated, you need to have cookies.
url = 'http://localhost:8000/wp-admin/media-new.php'
data = {
'post_id': '0',
'_wp_http_referer': '/wp-admin/media-new.php',
'_wpnonce': wp_nonce,
'action': 'upload_attachement',
'html-upload': 'Upload'
}
files = {'async-upload':('1.jpg', open('1.jpg', 'rb'))}
headers = {'Cookie': my_cookies}
upload_result = session.post(url, data=data, files=files, headers=headers)
I'm assuming that you have acquired valid cookies from your browser. If you want to get authenticated with requests check my answer to this post: login-wordpress-with-requests

Dynamic error style password field accounts-core in Meteor

I am using accounts-core package in meteor to make my registration form in my application.
I configure own custom validation field in password. i.e.
var password = AccountsTemplates.removeField('password');
AccountsTemplates.addField({
_id: 'password',
type: 'password',
required: true,
displayName: 'Password',
re: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/,
errStr: 'At least 8 characters, 1 uppercase, 1 lowercase and 1 number'
});
Now i want to show error message with different style according to what character user missed to type. Something like:
As per Documentation : Field Configuration we need give errStr when field is configured.
And we can write func for custom validation:
AccountsTemplates.addField({
...
func : function(pwd){
... // check your password
}
...
});
But How can i pass dynamic markup to show error message?

Symfony 2 - Validate a field with NotBlank & Type constraints

I am having problems validating a form component when i have added both NotBlank and Type validation to an integer field.
My validation.yml looks like the following:
Acme\StoreBundle\Entity\Foo:
properties:
bar:
- NotBlank:
message: You must specify a bar
- Type:
type: integer
message: bar must be an integer
My FormType file looks like the following:
$builder->add('bar', 'integer', array(
'label' => bar',
'error_bubbling' => true
));
When I type 'abc' into the field and submit, validate the form and getErrors(), the errors reported are -
This value is not valid.
You must specify a bar.
any ideas whats going wrong? I'm running Symfony 2.0.10
I had the same problem. In the end, I used a normal 'text' field, and made my own 'Integer' validator which uses regular expression.
I am not sure but maybe this helps:
$builder->add('bar', 'integer', array(
'label' => bar',
'invalid_message' => 'bar must be an integer'
'error_bubbling' => true
));
Check this out
Your problem may be related to this issue. From the discussion of the issue it seems that the solution of the problem is replacing line 40 of the DelegatingValidator.php with this code
if ($form->isRoot() && $form->isSynchronized()) {
I haven't tested it though. You can try and tell about the result :).
I am pretty late but this can help
validation.yml
contactNo:
- NotBlank: ~
- Regex:
pattern: '/\d/'
match: true
message: Your contact no. must be a number
- Length:
min: 10
max: 15
minMessage: 'You contact no. must be at least {{ limit }} digits.'
maxMessage: 'You contact no. can not be greater than {{ limit }} digits.'

Resources