How to check if there is a duplicated field name within my form before register? - react-final-form

I am trying to identify whether within my react final form I have a duplicated name field and then throw an error. I have tried to use a decorator on registerField() and it seems to work fine, however, on a re-render this will not work. I have also tried to use getRegisterFields() but it seems like its either removing duplicate names or it never registers 2 fields with the same name.
What would you think would be a perfect approach here? Much appreciated.

Related

No geometry value provided at geodjango admin

I'm trying geodjango for my pet project and everything looks good with an exception...
In my model I have a field like this:
coordinates= models.PointField(srid=4326,default='POINT(0.0 0.0)')
and my admin extends from admin.OSMGeoAdmin but when I open a new model instance in the admin, I'm not seeing the '0.00,0.00' point selected in the map and if I try to save the document, I'll get 'No geometry value provided'. Like if the admin just Can't put the point in the map.
Also, if I try using the shell, I can save instances w/o problem and get the field with the default value POINT(0.0 0.0).
Am I missing something in the admin?
Thanks for any hint!
I have the same issue.
It's weird. What is getting POSTed makes no sense.
At the point of hitting submit the textarea has the correct geometry value (as I put an onsubmit on the form that outputs me this value).
But what gets submitted is not that value.
So I turned JS off... wow. The correct value is submitted and I am a little happier, but this is not a solution.
But what javascript is doing this I don't know.
I've tried this with Django 1.3 and 1.4.
Have you had any luck?
update. one more 'solution'... override openlayers.html and turn the textarea to a standard text input. wow. works again.
SOLVED!
So mine took some digging... but my admin uses tinymce... Tinymce works on textareas yeah.... well it screwed up the widgets textarea, but ever so silently.
editor_deselector : "vWKTField"
Well, after toying around with open layers.html (THANKS noisyboiler!) I found there is an attribute on the OSMGeoAdmin display_wkt, setting it to True will show the textArea without hacking the template.
For entries with existing points, it contains a value in this format:
SRID=3857;POINT(890338.8453418 -1109499.0330941)
So I just change my Point Field to:
coordinates= models.PointField(srid=4326,default='SRID=3857;POINT(0.0 0.0)')
What I understand from Spherical Mercator is that 4326 is for two-dimensional maps, but seems like google Maps uses 3857 which includes a spherical projection.
Now works!

Access 2010 form not displaying query

I'm sure this is an easy fix but I can't seem to find it. I just have a form, that will be a subform of another, that needs to display the results of a query.
The query is simple enough, just displays all fields of records that fall between specified dates. The query works great, but when I attach it to the form as its record source it doesn't display the data. I can see the correct amount of record selectors so I know its understanding the query but its as if all fields are hidden!
I have also tried building a query to the forms record source that was simply Select query.* From query. Oddly I have had this working before but I had to specify every field. What I mean is:
Select title From query
Select type From query
Select date From query
...
And so on for all the fields but this seems foolish, can anyone think of what I may be doing wrong?
Thanks in advance!
Edit, forgot to mention I also tried the foolish solution that I mentioned above and it didn't work so its definitely some issue that I'm not seeing, some property that's probably not appropriately set
#sshekhar well its not really code at the moment I'm using Access 2010. I have a form that needs to display a subform that executes this query of displaying records that have a data field that fall between dates specified by the user. The query works and displays the correct records, but the form that it is attached to only shows the record selectors and all the fields appear to be "hidden." I thought it may be one of the form's properties set incorrectly but I checked on the test form from another database that I used and each have what appears to be identical settings. So I'm at a loss!
So it turns out even though I using a query that holds all the fields it will not display the content unless you go to the Add Existing Fields and add all the the fields you want to see. This seems really silly especially when the results in the query but at least its working now.
I had this problem and discovered that having the property DataEntry set to YES will only display new records. From Microsoft Help:
You can use the DataEntry property to specify whether a bound form
opens to allow data entry only. The Data Entry property doesn't
determine whether records can be added; it only determines whether
existing records are displayed. Read/write Boolean.

Can someone explain Rails behavior for multiple fields with identical names and ids?

I needed to create a input mask for a jQuery datepicker in my Rails app, where the first form field uses m/d/yy format and the datepicker populates a hidden input with the proper database format.
I was using SimpleForm, and so I extended my own input so that the input is preceded by the mask.
I got everything set up and when checking out the browser, it all just worked well before I thought I would be done.
The form ends up with two inputs for the same attribute, each with the same id and name. I never thought this would work. Checking the development log I only see one date getting submitted, the second of the two which is the one that has the proper format for the database.
Is this all okay? Should I take some extra steps even though this appears to work fine, and more importantly, can someone explain what's going on under the hood that results in this behavior?
Thanks!!
Rails uses the Hash params to store fields submitted. When you declare two or more inputs using the same name, it happens the same as if you do something like
h=Hash.new
h[:name]="foo"
h[:name]="bar"
Result is bar because the foo was overwritten. So the "winner" is always the field value which the browser last appended to postdata.
But if I where you, I would not rely on the browser that the second field gets appended at last.

How do i filter and validate form fields in symfony 1.4?

Im trying to integrate a content filtering API. My plan was to use pre/post validators but I've lost may way somehow.
What i need to do is send the values to the content filtering service. If the response comes back that the content has been filtered it will also return a modified value for the field (basic profanity filtering... matches are replace with asterisks). Thats all well and good i can throw validation errors no problem - simple stuff.
However i dont want just throw errors. What needs to happen is that validation errors are thrown as normal, but the values are modified in the form for re-display.
Basically if someone posts something naughty i want them to get a validation error saying their post has been modified, they can re-submit the now "clean" post, or they can go about editing it to make it clean without the word replacements.
But do clean on a validator either throws an error OR returns cleaned values, not both. How can i go about implementing both? This will be used on many different forms with many different field names, so modifying methods on the form or a form base class isnt really an option - it needs to happen in the validation sub-framework somehow.
You can adjust this plugin for your needs http://www.symfony-project.org/plugins/WebPurifyPlugin

Site column does not get deleted

I have a Site column which i delete programatically using the following code. I have already removed all references to the field previously. However, even if there is not error, it goes to fieldtodelete.Delete() and steps through the next line. However, when i check the Site Column collection using SPM2007 or via the UI the site column is still there.
Dim fieldtodelete As SPField
Try
fieldtodelete = site.RootWeb.Fields.GetFieldByInternalName(name)
'site.RootWeb.Fields.GetFieldByInternalName(name)
fieldtodelete.Delete()
Catch ex As Exception
Console.WriteLine("Field: {0} was not deleted", name)
Return 0
End Try
Any ideas on why sharepoint does this? Also, there are 2 fields with the same name, i am not sure if this has a direct effect on this. I want to delete both.
Thanks
Since there are 2 fields with the same name, their internal names are likely different than the Name. Are you sure the line
fieldtodelete = site.RootWeb.Fields.GetFieldByInternalName(name)
is actually returning a valid SPField? If not, you will need to find the internal names of the fields, which don't necessarily match up to the Names.
EDIT: Since you said that you are getting the fields back, I realized you aren't calling site.RootWeb.Update() after deleting the field. That should fix the issue.

Resources