form-fields


Passing array via hidden fields to rails

一曲冷凌霜 提交于 2020-01-13 09:10:11
问题 i have a hidden_tag like this in my form <%= f.hidden_field :loc , {:multiple => true} %> which renders to <input id="business_loc" multiple="multiple" name="business[loc][]" type="hidden" style="color: rgb(175, 175, 175); " value=""> currently am setting the business_loc value as a comma seperated string hoping rails would recognize when submit the form. But this is the value i got on the server side "loc"=>["80.22167450000006,13.0454044"] instead "loc"=>[80.22167450000006,13.0454044] how do

How can you manually render a form field with its initial value set?

大城市里の小女人 提交于 2020-01-05 05:54:34
问题 I'm trying to render a form's fields manually so that my designer colleagues could manipulate the input elements within the HTML instead of struggling in Python source. ie. Instead of declaring form fields like this... {{ form.first_name }} .. I actually do ... <label for="id_first_name">Your name:</label> <input type="text" value="{{ form.first_name.somehow_get_initial_value_here }}" name="first_name" id="id_first_name" class="blabla" maxlength="30" > {% if form.first_name.errors %}<span>***

Django: Display NullBooleanField as Radio and default to None

血红的双手。 提交于 2020-01-01 15:48:28
问题 I am successfully implementing NullBooleanField as radio buttons in several ways but the problem is that I can not set the default value to None. Here is the code: models.py: class ClinicalData(models.Model): approved = models.NullBooleanField() ... forms.py: NA_YES_NO = ((None, 'N/A'), (True, 'Yes'), (False, 'No')) class ClinicalDataForm(ModelForm): approved = forms.BooleanField(widget=forms.RadioSelect(choices=NA_YES_NO)) class Meta: model = ClinicalData I tried the following methods: Set

How to prevent form elements from pre-populating in Chrome

▼魔方 西西 提交于 2019-12-24 01:15:39
问题 I am building a Bootstrap form and the email and password form elements show with pre-populated data from some other or some earlier form login on a different site. The Chrome browser is auto-populating the form elements. Is there an HTML attribute of method in Bootstrap to force these form elements to null or empty on page load? 2015-10-29 -- here's the markup: <form autocomplete="off" method="post" role="form"> <div class="form-group"> <input name="formSubmitted" type="hidden" value="1"> <

Extract Editable Fields from a PDF in Objective-C

此生再无相见时 提交于 2019-12-21 17:42:39
问题 I've been researching working with PDFs in my iOS app for a while now. I've figured out a few pieces of the puzzle like scanning for operators and displaying the PDF in a UIWebView. However, what I really need to do is identify editable fields within a PDF document. Ideally I would like to be able to interact with the fields directly but that sounds very difficult and not an obvious first step. I am already interfacing with a Windows service that can manipulate PDFs in this way and could

Use Sonata Field Type on normal Form Class

青春壹個敷衍的年華 提交于 2019-12-21 05:32:10
问题 I'm trying to insert custom sonata form field type on the front page, not in SonataAdmin, something like this: $form = $this->createFormBuilder($content) ->add('titleEs', 'text', array('required' => true, 'label' => 'label.title.spanish', 'attr' => array('class' => 'col-xs-12 form-control input-lg'))) ->add('contentEs', 'ckeditor', array('required' => true,'label' => 'label.content.spanish', 'attr' => array('class' => 'col-xs-12'))) ->add('titleEn', 'text', array('required' => true,'label' =>

Using Javascript to Open a New Page and Populate Form Values There

时光毁灭记忆、已成空白 提交于 2019-12-18 03:49:07
问题 I am using JavaScript in a bookmarklet to populate form elements on a website: javascript:var f = document.forms[0]; f.getElementsByTagName('input')[0].value = 'myname'; f.getElementsByTagName('input')[1].value = 'mypassword'; f.getElementsByTagName('input')[2].click This works. However what I would like to create is a bookmarklet so that it opens the target page, and populates the values there; however it seems that onces the page is loaded, other JavaScript codes are not executed. So, the

Django: How to write a clean method for a field that allows mutiple file uploads?

浪尽此生 提交于 2019-12-08 01:11:00
问题 I have a form for uploading images. If I follow Django's standard for cleaning a specific field attribute of a form, this is what my clean method would typically look like: class UploadImagesForm(forms.Form): image = forms.FileField() def clean_image(self): file = self.cleaned_data['image'] if file: if file._size > 15*1024*1024: raise forms.ValidationError("Image file is too large ( > 15mb ).") return file else: raise forms.ValidationError("Could not read the uploaded file.") However, I'm

Django: How to write a clean method for a field that allows mutiple file uploads?

强颜欢笑 提交于 2019-12-06 12:42:41
I have a form for uploading images. If I follow Django's standard for cleaning a specific field attribute of a form , this is what my clean method would typically look like: class UploadImagesForm(forms.Form): image = forms.FileField() def clean_image(self): file = self.cleaned_data['image'] if file: if file._size > 15*1024*1024: raise forms.ValidationError("Image file is too large ( > 15mb ).") return file else: raise forms.ValidationError("Could not read the uploaded file.") However, I'm using a form that allows multiple images to be uploaded at once, all through the same widget (ie, the

Django: Display NullBooleanField as Radio and default to None

試著忘記壹切 提交于 2019-12-04 12:38:21
I am successfully implementing NullBooleanField as radio buttons in several ways but the problem is that I can not set the default value to None. Here is the code: models.py: class ClinicalData(models.Model): approved = models.NullBooleanField() ... forms.py: NA_YES_NO = ((None, 'N/A'), (True, 'Yes'), (False, 'No')) class ClinicalDataForm(ModelForm): approved = forms.BooleanField(widget=forms.RadioSelect(choices=NA_YES_NO)) class Meta: model = ClinicalData I tried the following methods: Set default:None in the model and/or setting inital:None in the form and also in the view in the form

工具导航Map